Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
bffy_smmmers
5 years agoHelpful | Level 5
dbx.auth not working / getAccessTokenFromCode giving 400 response?
I'm trying to access the `getAccessTokenFromCode` method and I keep receiving a 400 error. On top of that, I can't seem to write the code and get it to work in the way it's written in the Auth ex...
- 5 years ago
I'm not sure I follow your message, but you should specify it in both places. The /oauth2/authorize page redirect_uri parameter specifies where to send the user after they authorize the app, and the 'redirectUri' you pass to 'getAccessTokenFromCode' is just a string sent up in a /oauth2/token API call to verify that it matches.
Greg-DB
Dropbox Community Moderator
5 years agoThanks! So the error message in this case is "redirect_uri mismatch", which indicates that the 'redirectUri' you're passing to 'getAccessTokenFromCode' doesn't match the redirect_uri value on the /oauth2/authorize URL used to retrieved the authorization code. It needs to either be omitted in both places, or otherwise match exactly.
Can you share the 'redirectUri' value you're using, as well as the /oauth2/authorize URL?
Also, regarding your other question, if you have "linked accounts" you'll be prompted to choose which to connect to the app. Otherwise, you can use the "Sign out" link in the account dropdown on the app authorization page to sign out of the current account and then sign in to another to authorize the app there.
bffy_smmmers
5 years agoHelpful | Level 5
hi Greg-DB - me again.. for some reason i am not actually able to see the "linked account" screen. to switch users, or to even authorize the app. when i go through the auth flow i am just automatically redirected and authorized. unless i sign out of dropbox in a different window. is there someting in the code i need to update here?
static async getAuthUrl(state: string😞 Promise<string> {
const dbx = newOAuthInstance();
const res = await dbx.getAuthenticationUrl(
REDIRECT_URI,
state,
'code',
'offline',
);
return res.toString();
}
- Greg-DB5 years ago
Dropbox Community Moderator
If you're signed in to an account that has already authorized the app, you may not be explicitly asked to authorize it again, and may instead just be redirected through the flow automatically. Check out the 'force_reapprove' parameter on /oauth2/authorize.
- bffy_smmmers5 years agoHelpful | Level 5
Also, Greg-DB im using the JavaScript SDK. I dont see how to inject forceReapprove/force_reapprove with the current methods im using on node backend (getAuthenticationUrl, getAccessTokenFromCode).
- Greg-DB5 years ago
Dropbox Community Moderator
That's correct, that parameter isn't currently implemented in the Dropbox JavaScript SDK, but I'll be sure to pass this along as a feature request. You can add it to the /oauth2/authorize URL in your app's own code though, by modifying the URL returned by getAuthenticationUrl.
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!