We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
lalith-mcw
3 years agoExplorer | Level 3
After token refresh contents still need authorization to download
import dropbox
box = dropbox.Dropbox(oauth2_refresh_token=<Refresh_Token>, app_key=<app_key>, app_secret=<app_secret>)
With logging info able to see the following message:
```
INFO : R...
- 3 years ago
Hi again lalith-mcw,
I just tried it out and it's working for me. Are you certainly passed the refresh token to and not something else? 🧐 Also to work correctly, the app key must match to the refresh token (for PKCE app secret is optional, but when given must be correct and matching too).
You can check if your params are correct using following command line:
curl https://api.dropbox.com/oauth2/token -d grant_type=refresh_token -d refresh_token=<YOUR_REFRESH_TOKEN_HERE> -d client_id=<YOUR_APP_KEY_HERE>
Replace <YOUR_REFRESH_TOKEN_HERE> to the content of refresh_token var and <YOUR_APP_KEY_HERE> to the content of key var from your code. If everything is correct you will get back something like:
{"access_token":"sl.AbX9y6...","expires_in":14400,"token_type":"bearer"}Otherwise, you will get appropriate error message and should fix whatever needed.
Good luck.
Add: You can get as working example one my earlier post here.
Здравко
3 years agoLegendary | Level 20
Hi again lalith-mcw,
I just tried it out and it's working for me. Are you certainly passed the refresh token to and not something else? 🧐 Also to work correctly, the app key must match to the refresh token (for PKCE app secret is optional, but when given must be correct and matching too).
You can check if your params are correct using following command line:
curl https://api.dropbox.com/oauth2/token -d grant_type=refresh_token -d refresh_token=<YOUR_REFRESH_TOKEN_HERE> -d client_id=<YOUR_APP_KEY_HERE>
Replace <YOUR_REFRESH_TOKEN_HERE> to the content of refresh_token var and <YOUR_APP_KEY_HERE> to the content of key var from your code. If everything is correct you will get back something like:
{"access_token":"sl.AbX9y6...","expires_in":14400,"token_type":"bearer"}Otherwise, you will get appropriate error message and should fix whatever needed.
Good luck.
Add: You can get as working example one my earlier post here.
lalith-mcw
3 years agoExplorer | Level 3
Thanks that did worked, this is where the whole confusion was. I was thinking the code generated here is `Refresh Token`. But realized this is just `Authorization Code` and checkouted out the solution here as well. Which had clear steps which mentions there are 3 types of tokens `Authorization Code`, `Refresh Token` & `Access Token` (Oauth Token)
Its better the body here is modified to `Authorization Code Generated` instead `Access Code Generated` just confused here.
Used the command here
curl https://api.dropbox.com/oauth2/token \
-d code=AUTHORIZATIONCODEHERE \
-d grant_type=authorization_code \
-u APPKEYHERE:APPSECRETHERE
And from the JSON generated above copied the `Refresh Token` and used it as a python request post() method to fetch the `json().access_token`
curl https://api.dropbox.com/oauth2/token \ -d refresh_token=REFRESHTOKENHERE \ -d grant_type=refresh_token \ -d client_id=APPKEYHERE \ -d client_secret=APPSECRETHERE
And finally it works with dropbox.Dropbox(<access_token>) thanks Здравко DB-Des Greg-DB for the help
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!