I will go straight to the question. How do I refresh the bit bucket token OAuth 2.0 using python requests.
According to https://developer.atlassian.com/cloud/bitbucket/oauth-2/ this is what they recommend.
$ curl -X POST -u "client_id:secret" \
https://bitbucket.org/site/oauth2/access_token \
-d grant_type=refresh_token -d refresh_token={refresh_toke
n} Only to get this {"error_description": "Invalid refresh_token", "error": "invalid_request"} Mainly I want to do this in python and here is my approach
import requests
auth = ("I put real client_id here", "and-i-put-secret-here")
params={"grant_type":"refresh_token", "refresh_token":"The-token-i-want-to-refresh"}
h={"Content-type": "application/json"}
ret = requests.post(refurl, auth=auth, params=params, headers=h)
# the response is 400 and when i do
ret.content
'{"error_description": "Unsupported grant type: None", "error": "invalid_grant"}'
The same error as the curl they recommended.
The question is how do I refresh the token.