Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,295,693
Community Members
 
Community Events
165
Community Groups

Failure to connect to Bitbucket cloud from another system.

I am trying to connect to my bitbucket cloud workspace from another system (XL Release) using Oauth2. I have created a client ID and secret key as per the instructions (https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/)

When attempting to connect I am getting the following error on XL Release:

Can't connect to Bitbucket Cloud.

Exception: HTTP response code 401 (Unauthorized)

I have provided the Access token URL as https://bitbucket.org/site/oauth2/access_token

I am not sure if I am missing anything.

Documentation is not clear and also there is no option to check the logs to see if I am able to hit the Bitbucket URL or not.

Any help would be appreciated.

Thanks a lot.

 

 

 

1 answer

1 accepted

0 votes
Answer accepted
Caroline R Atlassian Team Jul 30, 2021

Hi, @Shad!  

Thank you for reaching out to Atlassian Community!

Before anything, I would like to share with you all the steps to get the Access token, just to confirm you have followed the right process:

  • Access the workspace and click on Settings;

  • Click OAuth consumersAdd consumer;

  • Add at least the following information:

    • Name

    • Callback URL

    • The Permissions you want to give to this OAuth

  • Click Save;

  • Access the link:

    https://bitbucket.org/site/oauth2/authorize?client_id={client_id}&response_type=code
  • Replace the "{client_id}" with the Key generated on your OAuth

  • Click on Grant Access

  • You will be redirected to a URL that will contain a code (You will see something like this: code=XXXX on the URL)

  • Then, run the following code, replacing the Key and secret with the information on your OAuth (set in your workspace), and the code generated on the URL in the last step:

    curl -X POST -u <Key:Secret> https://bitbucket.org/site/oauth2/access_token -d grant_type=authorization_code -d code=<Insert the code here>
  • Then, you should receive an output that contains the token, something like this:

  • {"scopes": "pullrequest:write repository:delete pipeline:variable snippet:write project:write webhook team:write issue:write account:write wiki", "access_token": "XXXXXXX", "expires_in": 7200, "token_type": "bearer", "state": "authorization_code", "refresh_token": "XXX"}%
  • This will give you the Access token to authenticate.

  • If you would like to test this token, you can use the Access token to authenticate the following API:

    curl -X GET https://api.bitbucket.org/2.0/repositories --header ‘authorization: Bearer <insert the token here>’

If you follow all the steps mentioned above and face any issues, please share the error you received, and in case you need help in this process, I’ll be glad to assist you. 

Kind regards,
Caroline

Thank you very much Caroline.

I have a couple of follow-up question:

1. Does the token obtained using this process expire in 7200 seconds? If yes, what can be done to reuse it for longer time? When I created this token and used it to connect from the Digital.ai Release, it gives me a message that it was able to connect/authenticate successfully. And the same token continues to show a successful connection even after days of creating it.

To test if this is a false message while the token may actually expiring, when I change the token even by one character it fails to connect. So does it mean it is still active?

2. The other question I have is how to identify the Repository path if my account is a company account? In case of accounts created using personal email IDs, the path of the repository would be "TeamName/Repository" or "Username/Repository". In case of a company owned account, would the repository path be WorkspaceName/ProjectName/RepositoryName ? 

Any guidance would be much appreciated!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,170 views 2 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you