Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
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?
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".
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"
Hi there!
If you need more help you can view your support options (expected response time for a 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!