cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done 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: 

Do not get 'oauth1AccessSecret' while using OAuth V1

Do not get 'oauth1AccessSecret' while using OAuth V1

Jay_Nuggehalli
Explorer | Level 3

We are currenlty migrating API v1 to v2. While doing so we wanted to upgrade the tokens of our existing users but one of the required parameters to do so 'access secret' is missing in the v1 response.

 

We are getting the following response for OAuth v1 

 

{"access_token": "3XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "token_type": "bearer", "uid": "87878789", "account_id": "dbid:AANNJDHJFHFJKGFRJKFUYGFJK"}

 

How do we upgrade our old OAuth v1 users' access tokens?

1 Accepted Solution

Accepted Solutions

Re: Do not get 'oauth1AccessSecret' while using OAuth V1

Greg-DB
Dropboxer
If your access tokens don't have a separate "secret" portion, it sounds like you already have OAuth 2 access tokens.

Note that API v1 supports both OAuth 1 and OAuth 2 (whereas API v2 only supports OAuth 2), so you may already have been using OAuth 2 access tokens with API v1.

In that case, you don't need to migrate these tokens, and can directly use them with API v2.

View solution in original post

3 Replies 3

Re: Do not get 'oauth1AccessSecret' while using OAuth V1

Greg-DB
Dropboxer

Hi Jay, it looks like you're using the /1/oauth2/token_from_oauth1 endpoint to get an OAuth 2 access token from an OAuth 1 access token.

 

Based on the response you shared, that's working correctly. The "access_token" value there is the OAuth 2 access token.

 

OAuth 2 access tokens are different from OAuth 1 access tokens in that OAuth 2 access tokens only have one part, whereas OAuth 1 access tokens have two parts (a key and secret).

 

Once you have this OAuth 2 access token, you can use it to call both API v1 and API v2 using the OAuth 2 protocol for bearer tokens. I.e., you can just add an "Authorization" header with value "Bearer ACCESS_TOKEN_HERE".

Re: Do not get 'oauth1AccessSecret' while using OAuth V1

Jay_Nuggehalli
Explorer | Level 3

We currenlty have a bunch of dropbox user tokens using the V1 API.

 

When we used V1 API to get the access token we were not getting "access token secret" from the response.

 

Apparently, this "access token secret" is required by the Dropbox SDK to migrate V1 access token to V2 access token.

 

Also as already mentioned we are trying to use the Dropbox Java SDK 2.1.2 to perform the migration of access token.

 

Please find the code snippet below:

 

 

private String upgradeAccessTokenV1ToV2(String accessToken_V1) {
DbxOAuth1AccessToken oauth1AccessToken = new DbxOAuth1AccessToken(
accessToken_V1, "SECRET_NOT_AVAILABLE");

DbxAppInfo appInfo = new DbxAppInfo(config.getClientId(), config.getClientSecret());
// Get an OAuth 2 access token.
DbxRequestConfig requestConfig = new DbxRequestConfig(clientIdentifier);
DbxOAuth1Upgrader upgrader = new DbxOAuth1Upgrader(requestConfig,appInfo);
String oauth2AccessToken = "";
try {
oauth2AccessToken = upgrader
.createOAuth2AccessToken(oauth1AccessToken);
System.out.println("OAuth 2 access token obtained.");
} catch (DbxException ex) {
System.err.println("Error getting OAuth 2 access token: "
+ ex.getMessage());
}

return oauth2AccessToken;
}

 

As mentioned in the earlier post we do not get the Oauth version 1 token secret from the v1 API to plug in "SECRET_NOT_AVAILABLE"

Re: Do not get 'oauth1AccessSecret' while using OAuth V1

Greg-DB
Dropboxer
If your access tokens don't have a separate "secret" portion, it sounds like you already have OAuth 2 access tokens.

Note that API v1 supports both OAuth 1 and OAuth 2 (whereas API v2 only supports OAuth 2), so you may already have been using OAuth 2 access tokens with API v1.

In that case, you don't need to migrate these tokens, and can directly use them with API v2.

View solution in original post

Poll
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    Jay_Nuggehalli Explorer | Level 3
What do Dropbox user levels mean?
Need more support?