cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Invalid grant trying to get refresh token

Invalid grant trying to get refresh token

lubernar
Explorer | Level 3

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'

response = requests.post('https://api.dropboxapi.com/oauth2/token',
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 1

Здравко
Legendary | 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.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?