Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
Chan N.
11 years agoNew member | Level 1
authenticating your app (code has expired error)
Hi there,
I am following the steps mentioned here https://www.dropbox.com/developers/core/start/java. but when I run the java program for second time, it says that "code has expired (within the last hour)", "error": "invalid_grant".
What should I do?
Especially, my question is how to set the access to the app so that the code is gotten only once, then you never need to do it again and the access stays there.
I want to automatically send the user to the authorization URL and pass in a callback URL so that the user is seamlessly redirected back to my app after pressing a button? rather than directing the user to the login page?
Thanks in advance
7 Replies
Replies have been turned off for this discussion
- Ed11 years ago
Dropbox Staff
Hi there,
Sorry for the delayed response - are you still having issues?
- Andrew G.3411 years agoNew member | Level 1
Trying to sync an app on put it in and it says expired.windows with dropbox. I get the code sent to my phone and immediately put in in and it says expired.
- Robert S.11 years ago
Super User alumni
Moved to API Development.
- Greg-DB11 years ago
Dropbox Community Moderator
Chan, You're getting this error because each "authorization code" that you exchange for the access token is short-lived (just a few minutes) and can only be used once, so you can only use each one once, soon after retrieving it.
After that, you can just store and re-use the resulting access token that your app receives from the app authorization flow for each account. These access tokens don't expire automatically (though they can be manually revoked) so your app can re-use them without manual user intervention.
And yes, you can set this up to work without the manual/copy paste. The tutorial uses the flow without a redirect URI, but instead, for web apps, you'll want to use
DbxWebAuth:https://dropbox.github.io/dropbox-sdk-java/api-docs/v1.7.x/com/dropbox/core/DbxWebAuth.html
- Greg-DB11 years ago
Dropbox Community Moderator
Andrew, your post seems unrelated to this thread, so you'll likely be better served in the Bugs & Troubleshooting section:
https://www.dropboxforum.com/hc/en-us/community/topics/200203389-Bugs-Troubleshooting
- Andrew G.3411 years agoNew member | Level 1
Thank you for your response, the code was used within seconds of receiving it.
- Greg-DB11 years ago
Dropbox Community Moderator
In your first post you mentioned the error occurred on the second run. Are you only getting the error the second time, or do you also get the error on the first attempted use of a new authorization code? If it's the first use, can you post your code and output?
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!