Hello Bitbucket Support Team,
We are facing an authentication issue with Bitbucket REST API. We are trying to integrate Bitbucket with an AWS Lambda function to fetch PR and pipeline data for our internal DevOps chatbot.
Problem: All API calls return 401 Unauthorized, regardless of the authentication method used.
What we have tried:
Our setup:
tracxsystemspenny@tracxsystems.comhttps://api.bitbucket.org/2.0/repositories/tracxsystemsAuthorization: Bearer <token> and Authorization: Basic <base64(email:token)>
Questions:
Please advise on the correct authentication method for our account.
Thank you,
Penny
Tracxsystems DevOps Team
@Penny It appears that you are on Bitbucket Cloud since that is the URL that you are using. If you are on Data Center, you would be calling a URL on your Data Center instance. Is your repo at https://bitbucket.org/tracxsystems/<repo slug>? If so, then you are on Cloud. If your repo is at something like https://tracxsystems.com:<port>/... then you are on Data Center.
App passwords are no longer supported for APIs. you either need to generate an API Token associated with your account or set up OAuth for authentication. To set up an API token, you would go to your avatar and select Account Settings. From there, you would select Security and scroll down until you see API Tokens. Create a new token and submit it just the way you indicate above using Basic authorization.
You need to use Scoped Tokens for Bitbucket Cloud. I tested it with Classic (non-scoped) and it didn't work. When I created a Scoped Token, it worked for me.
Hope this helps. Good luck.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.