Your workflow is unique 👨‍💻 -  tell us how you use Dropbox here.

Forum Discussion

Dearbhla's avatar
Dearbhla
Explorer | Level 3
8 years ago
Solved

Migration from v1 to v2 API - automatic token upgrade

Hi   I'm wondering about the call to        https://api.dropbox.com/1/oauth2/token_from_oauth1   to automatically upgrade a user's token from the v1 to the v2 api. I have this working well in m...
  • Greg-DB's avatar
    Greg-DB
    8 years ago

    You don't need to be already authorized for API v2 to use this endpoint. This endpoint just requires the app key, secret, and OAuth 1 access token (key and secret), not an OAuth 2 access token.

     

    The issue you're running in to is that /2/auth/token/from_oauth1 uses "app authentication" (i.e., you should provide the app key and secret as Basic auth to authorize the HTTP call itself) but you're trying to use "user authentication" (i.e., you're trying to provide a Bearer token to authorize the API call itself). The expected authentication type is a field in the documentation here:

     

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

     

    You can find information on the different authentication types, e.g., "app authentication", here:

     

    https://www.dropbox.com/developers/reference/auth-types#app

     

    (This is a bit confusing in this case, since the /2/auth/token/from_oauth1 endpoint expects "app authentication", but also happens to take an access token key/secret as parameters to the API call.)

     

    So, for your HTTP request, you should instead use an Authorization header like this:

     

    Authorization: Basic <base64(APP_KEY:APP_SECRET)>

    The app authentication documentation elaborates on that example.

     

    We're also working on building this in to SwiftyDropbox itself, but that's not ready quite yet. 

About Dropbox API Support and Feedback

Node avatar for Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

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, Facebook or Instagram.

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!