9 months ago
I am trying to use the GraphQL API to build a custom workflow but I can't seem to authenticate properly to fetch the environments. My query is:
query environments($projectId: String!) {
environments(projectId: $projectId) {
edges {
node {
id
name
}
}
}
}I am testing in the GraphQL playground and I have set the header:
{"Project-Access-Token": "***"}I also have the variable set:
{ "projectId": "0c581521-a4fd-4a7f-934a-305d621b828c" }This seems to be an API issue (or maybe something wrong with the query?) since the following query works fine with the same header:
query {
projectToken {
projectId
environmentId
}
}Project ID: 0c581521-a4fd-4a7f-934a-305d621b828c
7 Replies
Same auth issue for the following:
fragment EnvironmentFields on Environment {
id
name
projectId
}
mutation environmentCreate($input: EnvironmentCreateInput!) {
environmentCreate(input: $input) {
...EnvironmentFields
}
}With variables:
{
"input": {
"projectId": "0c581521-a4fd-4a7f-934a-305d621b828c",
"name": "test",
"sourceEnvironmentId": "2183d30e-5e58-4c47-8c06-d88b34746ba6"
}
}Outputs:
{
"errors": [
{
"message": "Not Authorized",
"locations": [
{
"line": 57,
"column": 3
}
],
"path": [
"environmentCreate"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR"
},
"traceId": "9204502859819063550"
}
],
"data": null
}9 months ago
Please try using an account token.
Worked with an account token. Is there a way to tell which queries/mutations operate with project vs account tokens (other than auth failure of course)? This query + mutation operate within a project so seems like project token should technically work. Was hoping to use the most restrictive token for safety given I will have many workspaces/projects but not a huge deal for now. Thanks
9 months ago
Its not a project token, it's actually an environment token, so it will only work with queries specific to a single environment
Ahhh - that makes sense. The name of the token is misleading but all good. Thanks for the help
9 months ago
No problem!
9 months ago
!s
Status changed to Solved brody • 9 months ago