I want to access my Bitbucket Cloud workspace data using the GraphQL API, but I am getting an error that says "Auth category: API_TOKEN is not allowed in service bitbucket". The error message also says that only session-based authentication is allowed.
i am calling this endpoint
https://api.atlassian.com/graphql - POST
graphql query:
query Bitbucket {
bitbucket {
bitbucketRepositories(ids: [""]) {
id
name
href
}
}
}
and for authentication i am passing token in header:
{
"Authorization" : "Basic base64<email:token>"
}
but this query does not allow token authentication
Response:
{
"message": "Auth category: API_TOKEN is not allowed in service bitbucket",
"locations": [],
"extensions": {
"allowedAuth": [
"SESSION"
],
"presentedAuth": "API_TOKEN",
"classification": "IncorrectAuthException",
"aggUgcPiiSafe": true,
"errorSource": "GRAPHQL_GATEWAY"
}
}
so please anyone can help me out how to do session based authentication?
and also need help for followings:
What GraphQL queries can I use to get the following data:
1. get repo list
2. particular repo branch list
3. get particular repo pull requests
4. get particular repo commits
5. get particular repo all files content
Thanks
Hi Dhruv,
For session-based authentication, you can use https://bitbucket.org/gateway/api/graphql or https://{your-subdomain}.atlassian.net/gateway/api/graphql on browser, where https://{your-subdomain}.atlassian.net is the URL of a Jira Cloud instance that is connected to the Bitbucket Cloud workspace.
If the Bitbucket Cloud workspace is linked to a Jira instance, you can use the queries mentioned in the following post to discover Bitbucket repositories linked to Jira, get the workspace of a repo, and list repos in a workspace:
Otherwise, I'm afraid it is not possible to get the ARIs needed for the queries.
If you run this query:
query getWorkspace {
bitbucket {
bitbucketRepository(id: "some-id") {
name, workspace {id, name}}
}
}
You can double-click the part bitbucketRepository in the editor, and you will see what authentication is allowed for this:
If you then select BitbucketRepository in this panel, you can then see in the left sidebar documentation with the available fields.
Branches, pull requests, commits, and source code of the repo cannot be retrieved with GraphQL at the moment. You can use Bitbucket Cloud REST APIs instead:
Kind regards,
Theodora
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.