cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know what we learned at IBC? Check out our learnings on media, remote working and more right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Issue in generating access token

Issue in generating access token

Mostafa Ezzat
Explorer | Level 4
Go to solution

Hello, I faced many issues in generating access token 

 

First, I have here access code generated <REDACTED>


Second trying to execute this curl : 

curl https://api.dropbox.com/oauth2/token \     -d code=<REDACTED> \     -d grant_type=authorization_code \     -d redirect_uri=https://api.dropbox.com/oauth2/token \     -u <REDACTED>

 It prints every time : 
{
"error": "invalid_grant",
"error_description": "redirect_uri mismatch"
}
However I have here the redirected links 

MostafaEzzat_0-1650622387439.png

 

31 Replies 31

Kloss
New member | Level 2
Go to solution

I was able to get my access code generated.

Then i open terminal as admin - and do the curl command replacing the app key and app secrete and inserting the access code.

Red XXXXX below are my account codes but replaced with xxxxx's


However I get a red error in Terminal. it says

Invoke-WebRequest : Parameter cannot be processed because the parameter name 'u' is ambiguous. Possible matches include: -UseBasicParsing -Uri -UseDefaultCredentials -UserAgent.
At line:1 char:128
+ ... xxxxxxxxxxxxxxxxxxxx -d grant_type=authorization_code -u xxxxxxx ...
+ ~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameter,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

 

 

:EDIT:I googled and found article to do the following command inside Terminal to fix this issue. - That seemed to work so I'll paste it here for anyone else who runs into this issue on Windows 11.
Remove-item alias:curl

Now I'm stuck at the message
"Enter host password for user 'xxxxxxxxxxxxxxxxxxxxxxxxx':

I've Typed password - I've copy pasted but the error I keep getting is

{"error": "invalid_client: Invalid client_id or client_secret"}

I know my app key and app secret is correct. And the host password I assume is my dropbox password to get into my account.

any thoughts on this?

Greg-DB
Dropbox Staff
Go to solution

@Kloss The original "-u" option shown earlier in this thread is an option for curl for specifying the Basic credentials (which in this case should be the app key and secret). It looks like in your environment it was getting sent to Invoke-WebRequest, where "-u" is ambiguous. I'm glad to hear you already sorted that out.

 

For this /oauth2/token call, you would specify the app key and secret, but not your account password. The "-u" option is a way to specify the app key and secret, in place of what would be the username and password in other contexts. So, to specify the app key and secret, you could use it like "-u <appkey>:<appsecret>", where <appkey> is your app key, and <appsecret> is your app secret; do not enter your account password.

Здравко
Legendary | Level 20
Go to solution

@Kloss wrote:

...
I know my app key and app secret is correct. And the host password I assume is my dropbox password to get into my account.
...


@Kloss, your account id (email) or password have nothing to do here! The only thing you need to authenticate is your application, nothing more. Check your shell syntax (might be some typing error, for instance). You account identification has already been performed in your browser. 😉

Good luck.

astronomy
New member | Level 2
Go to solution

Thank you. Your answer was very helpful to me. It should be in the guide articles.

calexmac
New member | Level 2
Go to solution

Hi Здравко

I have followed your (very generous) steps.  Every works fine... I get back the JSON I am expecting as per your post. ie I get the access token, a refresh token and bunch of other data.  However when I use the 'sl...' access token just generated to upload a file, I get the following error:

 

{"error_summary": "expired_access_token/...", "error": {".tag": "expired_access_token"}}

 

I have tried the flow you recommend several times to ensure I have all inputs correct, and get the same error.

Then I tried generating an access token directly from the app console for the app.  This returned the same error.

Any thoughts on where I should focus?

tx

c

Greg-DB
Dropbox Staff
Go to solution

@calexmac An 'expired_access_token' error indicates that the particular short-lived access token you used has expired, so you'd need to get a new one to continue making API calls. If you have a refresh token, you can do so by calling /oauth2/token with grant_type=refresh_token. Please refer to the messages at the beginning of this thread for more information.

The Kingdom
Explorer | Level 3
Go to solution

Does this method still work until now?

Здравко
Legendary | Level 20
Go to solution

Yes @The Kingdom, it does. It has never stopped. 😉 Do you have any issue? 🧐

Nice New Year holiday for everybody!

The Kingdom
Explorer | Level 3
Go to solution
Can you help me for this method? I don't have coding skill and i don't understand about coding.

Здравко
Legendary | Level 20
Go to solution

Hm.. 🤔 To be honest, I'm not sure what you ask me for. API/SDKs are software tools directed for usage in software project (or even simple client script). This is valid for any kind of such tools (no limit to Dropbox API/SDK). In the same context you need some basic coding skills, at least! My example here shows how authentication can work in a very basic and simplistic way. It's not the only way. The same way can be used for some prebuild third party software, but better ask the software provider how exactly, if you don'f feel yourself confident enough.

Hope this gives direction.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Здравко Legendary | Level 20
  • User avatar
    chibyk101 New member | Level 2
  • User avatar
    The Kingdom Explorer | Level 3
What do Dropbox user levels mean?