Our Community is in read-only mode until April 8th, learn more here. You can still search existing threads or get help via Dropbox Support, the Dropbox Help Center, or Learn.
Forum Discussion
OperationsDreaming
4 years agoNew member | Level 2
Unable to get long lived access tokens.
Hello there!
I'm trying to get an access token that doesn't expire. A long-lived access token. For now, when I generated an access token from the App Console, the session will expire after x ho...
- 4 years ago
Take a look on https://www.dropboxforum.com/t5/Discuss-Dropbox-Developer-API/Need-Permanant-Access-token-for-drop-box/td-p/583956 😉
In short - there is no more long lived access token and you should add refresh token in your code.
Hope this helps.
Greg-DB
Dropbox Community Moderator
3 years agomarksmithhfx Is that the exact code you're running? It looks correct, and it does work for me when I plug in my values. There may be something about how your client is formatting the request causing it to fail. Perhaps you can share the actual request/response you're getting (just redacting the sensitive values) so I can take a look.
marksmithhfx
3 years agoExplorer | Level 4
"Is that the exact code you're running?"
No, not exactly. I am using an OAuth2 package in the application development environment (it's like a fancy Visual BASIC) I am using. To get the refresh_token I was using this code (with redactions):
constant kAuthURL = "https://www.dropbox.com/oauth2/authorize"
constant kTokenURL = "https://api.dropboxapi.com/oauth2/token"
constant kClientID = "redacted" -- client here means this application, not this user
constant kClientSecret = "redacted" -- secret here is for this application, not this user
constant kScopes = ""
constant kPort = "54303"
since there is no parameter for token_access_type that is handled with:
put "offline" into tParams["token_access_type"]
then the call to OAuth2 itself...
OAuth2 kAuthURL, kTokenURL, kClientID, kClientSecret, kScopes, kPort, tParams
which successfully returned the array (actually JSON dictionary converted to array) I posted earlier.
This is the extent of the API I have, so I was trying to model the next step by writing:
put "refresh_token" into tParams["grant_type"]
put RefreshToken into tParams["refresh_token"] -- a var that contains the refresh token returned in the first step
-- I tested that both of these array values were properly formatted
and then calling:
OAuth2 kTokenURL, kClientID, kClientSecret, tParams
But all I get is a 404 Page not found error. I was hoping to get something more useful back (maybe you could think of a way I can do that?) so I could start to debug this, but all I get is the 404.
PS I did notice in the documentation that "authorization" is listed as a GET method and "token" as a POST method, but since I am not conversant in HTML that didn't mean anything to me. However, that might be the root cause of the problem. The application API might be formatting both as GET statements instead of the required POST one. (I should probably lookup GET and POST). Thanks
About Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.
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!