Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

How to do session based authentication to the Bitbucket Cloud GraphQL API

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     

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Oct 13, 2023

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:

Screenshot 2023-10-13 at 11.40.14.png

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events