We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
lubernar
2 years agoExplorer | Level 3
Invalid grant trying to get refresh token
Hello,
I want to catch changes that have been made in a spreadsheet in Dropbox by checking every 5 minutes.
I am using python and I tried this code:
f'response_type=code&token_access_type=offline'
Here I copy the code displayed on the webpage. This is my ACCESS_CODE_GENERATED.
Ant then I type:
BASIC_AUTH = base64.b64encode(f'{APP_KEY}:{APP_SECRET}'.encode())
headers = {
'Authorization': f"Basic {BASIC_AUTH}",
'Content-Type': 'application/x-www-form-urlencoded',
}
data = f'code={ACCESS_CODE_GENERATED}&grant_type=authorization_code'
data=data,
auth=(APP_KEY, APP_SECRET))
print(json.dumps(json.loads(response.text), indent=2))
And the output I get is
{ "error": "invalid_grant", "error_description": "code doesn't exist or has expired" }
I don't understand what is not working.
I would appreciate any help, thanks
1 Reply
- Здравко2 years agoLegendary | Level 20
Hi lubernar,
First of all, how long take between access code getting and using it? 🧐 This code is for single use only and is short lived 10~15mins. It sounds like, you kept it too long before usage.
Next thing, not signaled yet is usage of multiple basic authorizations at the same time (2 ways of all possible while 1 is needed and enough). By the way why you don't use the official Dropbox Python SDK? It would be easier. 😉
Good luck.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!