You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
bebuccio
12 months agoNew member | Level 2
Using /authorize passing client_id & redirect_uri next /token don't retrieve refresh_token
I have written a webapp to make the whole procedure to retreive a REFRESH_TOKEN so I can ask for a TOKEN when I want interacxt with DropBox.
When I invoke this my page, it send a GET to https://api.dropbox.com/oauth2/authorize with this params:
?client_id=<my_app_key>&redirect_uri=<myRedirectUri>&response_type=code
After this GET, I receive at my server (<myRedirectUri>) a GET with the param &code=<the_code_received>
With this code received, according with the documentation, DropBox give me the opportunity to get the REFRESH_TOKEN (this is "long-life" token).
To do this, when I receive at my site the GET on <myRedirectUri>, I send a POST https://api.dropbox.com/oauth2/token with this data:
{ "code": <the_code_received>,
"grant_type": "authorization_code",
"redirect_uri": <myRedirectUri>,
"client_id": <my_app_key>,
"client_secret": <my_app_secret>
}
As result of the POST I receive this result:
{"access_token": <the_token>,
"token_type": "bearer",
"expires_in": 14400,
"scope": "account_info.read files.content.read files.content.write files.metadata.read",
"uid": <the_id>,
"account_id": <the_account_id>
}
In this response it is missing the REFRESH_TOKEN.
If I do the same process but without the "redirect_uri" facility:
1) send a GET like https://www.dropbox.com/oauth2/authorize?client_id=<my_app_key>&token_access_type=offline&response_type=code
2) receive on my browser the code <the_code_received>
3) sending (i.e. with curl) a POST to https://api.dropbox.com/oauth2/token with data:
{ "code": <the_code_received>,
"grant_type": "authorization_code",
"client_id": <my_app_key>,
"client_secret": <my_app_secret>
}
I receive the correct data with the REFRESH_TOKEN
Why with the first method it doesn't work?
Where is the error?
bebuccio wrote:I have written a webapp to make the whole procedure to retreive a REFRESH_TOKEN so I can ask for a TOKEN when I want interacxt with DropBox.
When I invoke this my page, it send a GET to https://api.dropbox.com/oauth2/authorize with this params:
?client_id=<my_app_key>&redirect_uri=<myRedirectUri>&response_type=code
...
In this response it is missing the REFRESH_TOKEN.
If I do the same process but without the "redirect_uri" facility:
1) send a GET like https://www.dropbox.com/oauth2/authorize?client_id=<my_app_key>&token_access_type=offline&response_type=code
...
I receive the correct data with the REFRESH_TOKEN
...
Hi bebuccio,
Did you pass "token_access_type=offline" with the first variant too? 🧐😉
Hope this helps.
- ЗдравкоLegendary | Level 20
bebuccio wrote:I have written a webapp to make the whole procedure to retreive a REFRESH_TOKEN so I can ask for a TOKEN when I want interacxt with DropBox.
When I invoke this my page, it send a GET to https://api.dropbox.com/oauth2/authorize with this params:
?client_id=<my_app_key>&redirect_uri=<myRedirectUri>&response_type=code
...
In this response it is missing the REFRESH_TOKEN.
If I do the same process but without the "redirect_uri" facility:
1) send a GET like https://www.dropbox.com/oauth2/authorize?client_id=<my_app_key>&token_access_type=offline&response_type=code
...
I receive the correct data with the REFRESH_TOKEN
...
Hi bebuccio,
Did you pass "token_access_type=offline" with the first variant too? 🧐😉
Hope this helps.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,882 PostsLatest Activity: 10 hours agoIf 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 or Facebook.
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!