Forum Discussion

Rajarshi's avatar
Rajarshi
New member | Level 2
8 years ago

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

 

String my_app_key = "test1234";
String my_app_secret = "test567";
String client_app_key = "cltest123";
String client_app_secret = "cltest456";
 
DbxAppInfo appInfo = new DbxAppInfo(my_app_key, my_app_secret);
DbxOAuth1AccessToken oauth1AccessToken =
new DbxOAuth1AccessToken(client_app_key, client_app_secret);
 
DbxRequestConfig requestConfig = new DbxRequestConfig("myappname");
DbxOAuth1Upgrader upgrader = new DbxOAuth1Upgrader(requestConfig, appInfo);
String s = upgrader.createOAuth2AccessToken(oauth1AccessToken);
System.out.println("s====== " + s);

 

This is my code to fetch accesstoken key from V1.I am getting error of

"unexpected HTTP status code: 403: {"error": "Access token does not belong to this app."}"

 

Please help me out.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff
    This error message indicates that the access token you're using (client_app_key and client_app_secret in your code) doesn't correspond to the app key and secret (my_app_key and my_app_secret in your code) that you're using.

    When making this case, these pairs needs to match. That is, the access token you're trying to upgrade must have originally been retrieved using an app key and secret for the same app as you're using now.

    So in this case, you'll need to swap in the correct app key and secret (my_app_key and my_app_secret in your code) to be able to upgrade this access token (client_app_key and client_app_secret in your code).
    • Rajarshi's avatar
      Rajarshi
      New member | Level 2

      Thank You very very much Greg. It's really help.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,945 PostsLatest Activity: 2 hours ago
351 Following

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 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!