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

get refresh token code fails

David Lucas October 26, 2021

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
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 29, 2021

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

David Lucas October 28, 2022

Thank you very much for the response, I appreciate it.

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 28, 2022

You are very welcome, please feel free to reach out if you ever need anything else!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events