cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

How to get OAuth2 access token from OAuth1 token and secret with API v2

How to get OAuth2 access token from OAuth1 token and secret with API v2

saurabh6790
Explorer | Level 3
Go to solution

hi,

 

While creating an OAuth2 access token from OAuth1, I am getting error saying 

 

Error in call to API function "auth/token/from_oauth1": Invalid value in HTTP header "Authorization": "Bearer lZRzKu_9W****BSRr9Ul*****1inv****XSNQmj"%

 

Referred Documentation: https://www.dropbox.com/developers/documentation/http/documentation#auth-token-from_oauth1 

 

Ran command as:

curl -X POST https://api.dropboxapi.com/2/auth/token/from_oauth1 \
    --header "Authorization: Bearer lZRzKu_9W****BSRr9Ul*****1inv****XSNQmj" \
    --header "Content-Type: application/json" \
    --data '{"oauth1_token": "u1a8mamjaz0bzwqn","oauth1_token_secret": "ai******73di"}'

 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

Apologies for the confusion. The curl example in the documentation and API Explorer for /2/auth/token/from_oauth1 are unfortunately incorrect. I'll let the team know to fix that. 

That endpoint actually uses app authentication ( https://www.dropbox.com/developers/reference/auth-types#app ), so a bearer access token isn't necessary. This is what the curl example should look like: 

curl -X POST https://api.dropboxapi.com/2/auth/token/from_oauth1 \ 
    -u "APP_KEY:APP_SECRET" \ 
    --header "Content-Type: application/json" \ 
    --data "{\"oauth1_token\": \"OAUTH1_TOKEN_KEY\",\"oauth1_token_secret\": \"OAUTH1_TOKEN_SECRET\"}"

View solution in original post

8 Replies 8

Greg-DB
Dropbox Staff
Go to solution

Apologies for the confusion. The curl example in the documentation and API Explorer for /2/auth/token/from_oauth1 are unfortunately incorrect. I'll let the team know to fix that. 

That endpoint actually uses app authentication ( https://www.dropbox.com/developers/reference/auth-types#app ), so a bearer access token isn't necessary. This is what the curl example should look like: 

curl -X POST https://api.dropboxapi.com/2/auth/token/from_oauth1 \ 
    -u "APP_KEY:APP_SECRET" \ 
    --header "Content-Type: application/json" \ 
    --data "{\"oauth1_token\": \"OAUTH1_TOKEN_KEY\",\"oauth1_token_secret\": \"OAUTH1_TOKEN_SECRET\"}"

jayanthi123
New member | Level 2
Go to solution

i couldn't get token in both of the ways .

https://www.dropbox.com/developers/reference/auth-types#app - tried  . not working . it throws error like v1_retried.

 

https://www.dropbox.com/developers/documentation/http/documentation#auth-token-from_oauth1 - it always throws invalid client info .   i need to get access token using typescript on server side . can you provide 

solution  for this issue ?

Greg-DB
Dropbox Staff
Go to solution

@jayanthi123 The "OAuth 1" functionality discussed in this thread is only for converting pre-existing old OAuth 1 access tokens to OAuth 2. If you're just starting now, you wouldn't have any OAuth 1 tokens and so shouldn't use that.

 

Instead, to get an OAuth 2 access token for the end-user, you should implement and use the OAuth app authorization flow. You can find information on that in the Dropbox OAuth Guide, and the Dropbox OAuth 2 documentation. Specifically, that involves the user of the 'www.dropbox.com/oauth2/authorize' page, documented here, and possibly the /oauth2/token endpoint, documented here, depending on which OAuth flow you're using.

 

I also highly recommend using one of the official SDKs, if possible, as they'll do much of the work for you.

rishutiwari
Explorer | Level 3
Go to solution
curl -X POST https://api.dropboxapi.com/2/auth/token/from_oauth1 \ 
    -u "APP_KEY:APP_SECRET" \ 
    --header "Content-Type: application/json" \ 
    --data "{\"oauth1_token\": \"OAUTH1_TOKEN_KEY\",\"oauth1_token_secret\": \"OAUTH1_TOKEN_SECRET\"}"

Hello,

can anyone help me how to get the oauth1_token and oauth1_token_secret because when i hit this api  it  given me this error

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

 

Greg-DB
Dropbox Staff
Go to solution

@rishutiwari You should only use the /2/auth/token/from_oauth1 endpoint if you have old OAuth 1 access token keys and secrets stored, e.g., retrieved using OAuth 1 for API v1, which is now retired. If you don't already have any of those to convert, you shouldn't use this endpoint. Please refer to my earlier comment on this thread for more information.

rishutiwari
Explorer | Level 3
Go to solution

ok thanks,

Could you help me with this endpoint :

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

what we given in the <Authorization code>

and what we keep in the grant_type.because i couldn't find out what those parameter to be set and got the proper response.

rishutiwari
Explorer | Level 3
Go to solution

I resolved it..Thanks

l0k1
New member | Level 2
Go to solution
Hi rishutiwari, Glad to hear about U resolved it. Could you please tell me how to deal with the 4XX error while using new end point "https://api.dropboxapi.com/oauth2/token". That would be really helpful. Thank you.
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    l0k1 New member | Level 2
  • User avatar
    rishutiwari Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?