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

saqib-shafique's avatar
saqib-shafique
Explorer | Level 3
8 months ago

Access Code not working when calling /oauth2/authorize with call back URL

 I have made an API which calls /oauth2/authorize to get access code which is used to get access token and refresh token, since this will be used in an automated process, when I call /oauth2/authorize without callback url, the code I get it works by copying and using in

/oauth2/token, but if I use it with callback URL it always returns "response_body": "{\"error\": \"invalid_grant\", \"error_description\": \"code has already been used\"}".
Call back url(
http://localhost:5000/callback) is configured correctly, otherwise it should not be working when using code manually. 

https://www.dropbox.com/oauth2/authorize?client_id={CLIENT_ID}&token_access_type=offline&response_type=code&redirect_uri={REDIRECT_URI}
"grant_type":"
authorization_code"

any assistance will be really helpful.
  • Hi saqib-shafique,

    As the error message says, you have tried your code more than once. 🙂 This code is for single time use only. Even more - if not some copy/paste mistake, your URL is incorrect. The ending ("grant_type":"authorization_code") has nothing to do there. If you cannot get in touch/understand with your error, post relevant code snippet letting the mistake reproduction here, so we may comment it. 😉

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,888 PostsLatest Activity: 7 hours ago
326 Following

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 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!