You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
- My first access token get expired, now I want a new token without any User interface.
- I tried below in terminal,
curl -X POST -u "{key}:{secret}" https://bitbucket.org/site/oauth2/access_token -d
grant_type=refresh_token -d refresh_token={refresh_token}
but getting, below error
{"error_description": "Invalid refresh_token", "error": "invalid_request"}
Questions :
1. What parameter should we pass to refresh_token? we need a new access token then why need this field?
I tried, expired token and new access token(created using UI) as well but it not worked
Please help me to understand what parameter should we pass to the refresh_token
And how can I generate new token using terminal/curl
Thanks
Hi Arun,
When you generated your very first access token with a command like
curl -X POST -u "{key}:{secret}" https://bitbucket.org/site/oauth2/access_token -d grant_type=authorization_code -d code={code}
the output should have been like this:
{
"access_token" : 5cEig-w1wXrlbM876XY1Nu-w5WfObqP0EOYo2JOPzs615QxZTqI9z8Gsy_21yX23Uspwblt8eKeBAcwpCrHY=,
"scopes": "repository",
"expires_in" : 7200,
"refresh_token" : 4Etiw6UP808AU3rIoUW,
"token_type" : bearer
}
You need to use the value of the field 'refresh_token' above in your call.
Afterwards, when you execute the following command with this value for the refresh token
curl -X POST -u "{key}:{secret}" https://bitbucket.org/site/oauth2/access_token -d grant_type=refresh_token -d refresh_token={refresh_token}
you will get in the output a new authorization code, and a new refresh token which you can use after the 2 hours expiry, and so on.
Please feel free to let me know if you have any questions.
Kind regards,
Theodora
Hi Theodora
Thanks for quick response.
curl -X POST -u "{key}:{secret}" https://bitbucket.org/site/oauth2/access_token -d grant_type=authorization_code -d code={code}
When we are using the {code}, parameter do we have any expiry for it? Because it seems get invalid once get used.
{"error_description": "The specified code is not valid.", "error": "invalid_grant"}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Arun,
The following command
curl -X POST -u "{key}:{secret}" https://bitbucket.org/site/oauth2/access_token -d grant_type=authorization_code -d code={code}
you only use it once, in the beginning.
After the first time you use it, you execute the other command:
curl -X POST -u "{key}:{secret}" https://bitbucket.org/site/oauth2/access_token -d grant_type=refresh_token -d refresh_token={refresh_token}
After the 2 hours expiry, you also use
curl -X POST -u "{key}:{secret}" https://bitbucket.org/site/oauth2/access_token -d grant_type=refresh_token -d refresh_token={refresh_token}
This will give you both an authorization code and a refresh token to use the next time you execute it.
Does this help?
Kind regards,
Theodora
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.
when executing
curl -X POST -u "{key}:{secret}" https://bitbucket.org/site/oauth2/access_token -d grant_type=authorization_code -d code={code}
{"error": "invalid_grant", "error_description": "The specified code is not valid."}
what's the problem then?
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.