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,300,104
Community Members
 
Community Events
165
Community Groups

get refresh token code fails

curl -X GET https://bitbucket.org/site/oauth2/authorize?client_id={my_client_id}&response_type=code

I use my own client_id above. 

get refresh token code fails. There is no output. Even if I do -o output.txt

 

If I take this string and put in a browser I get the code. (fails using curl)

I need this automated using curl. 

 

1 answer

0 votes

Hi David,

This code needs to be obtained from the browser, it is not possible to get it with curl. Please note though that this needs to be done once when you set up OAuth. Also, the call to get refresh tokens is different and you can use curl for that.

After you use this in a browser and get a code

https://bitbucket.org/site/oauth2/authorize?client_id={consumer_key}&response_type=code

then you can get an access token and a refresh token with a call like this:

curl -X POST -u "key:secret" https://bitbucket.org/site/oauth2/access_token -d grant_type=authorization_code -d code=huPPKResiPcsLaqjj4
Replace key with your consumer's key
Replace secret with the consumer's secret
Replace the code value in there (huPPKResiPcsLaqjj4) with your code from the previous step

The output will include an access token you can use for up to 2 hours and a refresh token.

You can then use the refresh token to generate a new access token and refresh token with the following call:

curl -X POST -u "key:secret" https://bitbucket.org/site/oauth2/access_token -d grant_type=refresh_token -d refresh_token={2Eoiw6UJ707AD9aIyUR}
Replace key with the consumer's key
Replace secret with the consumer's secret
Replace the value of the refresh_token in there (2Eoiw6UJ707AD9aIyUR) with the one from the output of the previous curl command

This will give you another access token and refresh token. From then on, you can use the last call to generate new access and refresh tokens.

Please feel free to let me know if you have any questions.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
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,255 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