cancel
Showing results for 
Search instead for 
Did you mean: 

Migration token OAuth 1 to Oauth 2

305 Views
14 Comments
2 Kudos
Highlighted
Level 4

Migration token OAuth 1 to Oauth 2

Good Afternoon 

 

I triyed to update my OAuth 1 token to OAuth 2 through this HTTP request  :

https://api.dropboxapi.com/2/auth/token/from_oauth1

But the response looks like this : 

 

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

 

This kind of error references to the token information ( key:secret ).

 

The parameter's data  is :

 

$auth = $key.':'.$secret

 

array("oauth1_token"=>$auth,"oauth1_token_secret"=>$secret);

 

But the values was correct !( I think so...)

 

Whats going on ?

 

14 Replies
Dropboxer

Re: Migration token OAuth 1 to Oauth 2

To properly call /2/auth/token/from_oauth1, you will need four pieces:

 

- In the "Authorization" header, as Basic authentication, you need to provide the 1) app key and 2) app secret.

- In the request body, as JSON, you need to provide the 3) oauth1_token, i.e., the OAuth 1 access token key, and 4) oauth1_token_secret, i.e., the OAuth 1 access token secret.

 

These 4 strings would all be different strings.

 

Are you sending up all 4 of those?

Level 4

Re: Migration token OAuth 1 to Oauth 2

Thank you for quickly response.

 

1) Am I need to pass ( appKey: appSecret  ) in the Authorization header  ?  

3) oauth1_token is the appKey ?

4) oauth1_token_secret is the secret ?

 

My request is made by this way : 

oauth.png

 

 

Dropboxer

Re: Migration token OAuth 1 to Oauth 2

You do need to pass the app key and secret in the Authorization header.

The oauth1_token is not the app key, and the oauth1_token_secret is not the app secret. These all should be different strings.

The oauth1_token is the key portion of the OAuth 1 access token. The oauth1_token_secret is the secret portion of the OAuth 1 access token. You would get these from the stored OAuth 1 access tokens you have for users from when your app was using OAuth 1 on API v1. If your app doesn't have stored OAuth 1 access tokens, you shouldn't be using /2/auth/token/from_oauth1.
Level 4

Re: Migration token OAuth 1 to Oauth 2

I have to explain my situation...

 

I used to use SDK's maded to PHP, but with this nes upgrade with the new update this  become obsolete.

 

What the way i can get to migrate my app ?

 

I think this  https://api.dropboxapi.com/2/auth/token/from_oauth1 is the better way to i can finish the migration.

 

Can you help me ?

Dropboxer

Re: Migration token OAuth 1 to Oauth 2

Are you referring to this PHP SDK?

https://github.com/dropbox/dropbox-sdk-php

That SDK already used OAuth 2, not OAuth 1. If you were using that, you shouldn't have OAuth 1 tokens, so you don't need to use /2/auth/token/from_oauth1. You should just use the existing OAuth 2 access tokens with API v2.
Level 4

Re: Migration token OAuth 1 to Oauth 2

Yes thats it.

 

Howerver in this link " https://www.dropbox.com/developers/documentation " dont appear PHP language.

 

What I have to change exactly ?

 

The call of yours new Api ?

 

I just want to use "getMetadataWithChildren" and  "uploadFile", where i have to chage ?

 

Thank's for your attention in this case.

Level 4

Re: Migration token OAuth 1 to Oauth 2

Forget about it..

 

I get the access but, has something  change in getMetadataWithChildren parameters ?

 

Every path passed in the parameter return "null".

 

 

Dropboxer

Re: Migration token OAuth 1 to Oauth 2

The https://www.dropbox.com/developers/documentation link is for the HTTP interface itself.

We don't have plans for an official PHP SDK for Dropbox API v2, but you can use a third party library if you don't want to call the HTTPS endpoints directly:

https://www.dropbox.com/developers/documentation/communitysdks

For reference, to upload files, you can use:

https://www.dropbox.com/developers/documentation/http/documentation#files-upload

To get metadata for a file or folder, you should use:

https://www.dropbox.com/developers/documentation/http/documentation#files-get_metadata

To list the contents of a folder, you should use:

https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder
https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-continue

If you use a third party library instead of these endpoints directly, there should be corresponding methods for each of those.
Level 4

Re: Migration token OAuth 1 to Oauth 2

I'm almost done..

 

When I make upload chunked  in the moment to append the existing files already uploaded I got this response :

 

Unexpected HTTP status 409 {"error_summary": "incorrect_offset/.", "error": {".tag": "incorrect_offset", "correct_offset": 15}}

 

Why the correct_offset is 15 ?

 

The operation to calculate the byteOffset is wrong ?

 

Gratefull to help me in this situation !