Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
Aurelian R.
11 years agoNew member | Level 1
com.dropbox.core.DbxException$BadRequest: {"error_description": "code doesn't exist or has expired", "error": "invalid_grant"}
I uploaded successfully few files using the Dropbox API. But now I am receiving this message:
com.dropbox.core.DbxException$BadRequest: {"error_description": "code doesn't exist or has expired", "error": "invalid_grant"}
for this code
final String APP_KEY = "aaaaaaaaaaaaaaaa";
final String APP_SECRET = "sssssssssssssss";
DbxAppInfo appInfo = new DbxAppInfo(APP_KEY, APP_SECRET);
DbxRequestConfig config = new DbxRequestConfig("JavaTutorial/1.0",
Locale.getDefault().toString());
DbxWebAuthNoRedirect webAuth = new DbxWebAuthNoRedirect(config, appInfo);
// Have the user sign in and authorize your app.
String authorizeUrl = webAuth.start();
System.out.println("1. Go to: " + authorizeUrl);
System.out.println("2. Click \"Allow\" (you might have to log in first)");
System.out.println("3. Copy the authorization code.");
String code = "codexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
// Once the user has delivered the authorization code to our app, we can
// exchange that code for an access token via finish:
DbxAuthFinish authFinish = webAuth.finish(code);
String accessToken = authFinish.accessToken;
DbxClient client = new DbxClient(config, accessToken);
System.out.println("Linked account: "
+ client.getAccountInfo().displayName);
1 Reply
Replies have been turned off for this discussion
- Greg-DB11 years ago
Dropbox Community Moderator
You're getting this on the
webAuth.finishline, right? This error indicates that the authorization code you're using is invalid or expired. (These authorization codes currently expire after five minutes.)You should use the authorization only once, immediately after receiving it. After that, you can store and re-use the access token instead, without processing the authorization flow again.
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!