In your browser go to
https://bitbucket.org/site/oauth2/authorize?client_id={client_id}&response_type=code
Authorize under your bitbucket account.
After that, your browser will be redirected to
{your_redirect_link}/?code={code}
Use the code to make another request in a terminal:
curl -X POST -u "{client_id:secret}" https://bitbucket.org/site/oauth2/access_token -d grant_type=authorization_code -d code={code}
The reponse will be look like that:
{
"access_token": "some_long_string",
"scopes": "team webhook account issue wiki pipeline pullrequest project snippet",
"expires_in": 7200,
"refresh_token": "the_string_you_need",
"token_type": "bearer"
}
Now you can refresh access_token with request
curl -X POST -u "{client_id}:{secret}" https://bitbucket.org/site/oauth2/access_token -d grant_type=refresh_token -d refresh_token={refresh_token}
I order to use bitbucker api you need to generate a client_id (also known as a key) and a secret. You can do this in your settings page in OAuth section.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How can we do this all in curl. I tied it and it fails. I do not want to use the browser. I need automation to refresh my token.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have had 5 people try this and there is no output at all.
curl -o C:/tmp/refreshTokenCode.txt -X GET https://bitbucket.org/site/oauth2/authorize?client_id={MY CLIENT ID}&response_type=code
No output from curl
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi!
curl -X POST -u "client_id:secret" \
https://bitbucket.org/site/oauth2/access_token \
-d grant_type=refresh_token -d refresh_token={refresh_token}
https://developer.atlassian.com/bitbucket/api/2/reference/meta/authentication#refresh-tokens
Also, it will be nice if you provide pull request regarding that in this small routine reducer project. (https://github.com/AstroMatt/atlassian-python-api)
Cheers,
Gonchik Tsymzhitov
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.