We're making changes to the Community, so you may have received some notifications - thanks for your patience and welcome back. Learn more here.
Forum Discussion
2956work
2 months agoExplorer | Level 3
expired_access_token
When I do DropBox authentication in our Android app, it will jump to the DropBox App page. When I click Allow, the App reports an error: DropBox API auth error - {".tag" = "expired_access_token"}. The DropBox dependency we use is dropbox-core-sdk-3.1.1.jar. What is the reason for this? How should I deal with it?
- Greg-DBDropbox Staff
An 'expired_access_token' indicates that the API call failed because it was made with a short-lived access token that has expired. Please note that Dropbox issues short-lived access tokens which automatically expire after a few hours.
Apps can get long-term access by requesting "offline" access though, in which case the app receives a "refresh token" that can be used to retrieve new short-lived access tokens as needed, without further manual user intervention. Refresh tokens do not expire automatically and can be used repeatedly. You can find more information in the OAuth Guide and authorization documentation. There's a basic outline of processing this flow in this blog post which may serve as a useful example.
You mentioned you're using the official Dropbox API v2 Java SDK though. On Android, that would actually handle this for you automatically, as long as you use the authorization flow functionality provided by the SDK. (You should also upgrade to the latest version of the SDK, currently v7.0.0.) As long as you use the provided authorization functionality, starting with the
startOAuth2PKCE
method, it will handle the refresh process for you. You can find an example Android app here. For instance, you can see where that starts in the code here and how the result is handled here. When you use that functionality as shown, the SDK will catch those 'expired_access_token' errors for you automatically and get a new access token using the refresh token when needed.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,875 PostsLatest Activity: 2 years 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!