You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
MateusP
8 years agoHelpful | Level 6
How to migrate previous API v1 authentication to APIv2?
Hi All,
So I've successfully migrated my Android app to Dbx API v2 (hooray!) but there's one bit missing. I need to tranfer previous APIv1 authentication to APIv2 otherwise everyone will be fo...
- 8 years agoYes, OAuth 2 access tokens only have one piece. That is, each OAuth 2 access token is just one long string.
In your API v1 code, you're storing that via the access_token variable under DROPBOX_PREFS_SECRET.
In your API v2 code, you're storing that via the access_token variable under DROPBOX_PREFS_TOKEN.
(Part of the confusion may be that API v1 supported both OAuth 1 and OAuth 2. OAuth 1 access tokens are comprised of two pieces, a key and secret. API v2 only supports OAuth 2. OAuth 2 access tokens only have the one piece.)
MateusP
Helpful | Level 6
Thanks Greg, sounds simple. I was using OAuth2 and storing the token in SharedPrefs with API v1 (see below)
String access_token = session.getOAuth2AccessToken(); SharedPreferences prefs = getSharedPreferences(DROPBOX_PREFS, MODE_PRIVATE); prefs.edit.putString(DROPBOX_PREFS_KEY, "oauth2:").commit(); prefs.edit.putString(DROPBOX_PREFS_SECRET, access_token).commit();
and in API v2 I'm using...
String access_token = Auth.getOAuth2Token();
SharedPreferences prefs = getSharedPreferences(DROPBOX_PREFS, MODE_PRIVATE); prefs.edit().putString(DROPBOX_PREFS_TOKEN, access_token).apply();
So to get the token from API v1, I should be able to simply use the following .ine below? Sorry I'm getting a bit confused - is the APIv1 "secret" the same as APIv2 "token"?
String api1_token = prefs.getString(DROPBOX_PREFS_SECRET, null);
Many thanks,
M.
Greg-DB
8 years agoDropbox Staff
Yes, OAuth 2 access tokens only have one piece. That is, each OAuth 2 access token is just one long string.
In your API v1 code, you're storing that via the access_token variable under DROPBOX_PREFS_SECRET.
In your API v2 code, you're storing that via the access_token variable under DROPBOX_PREFS_TOKEN.
(Part of the confusion may be that API v1 supported both OAuth 1 and OAuth 2. OAuth 1 access tokens are comprised of two pieces, a key and secret. API v2 only supports OAuth 2. OAuth 2 access tokens only have the one piece.)
In your API v1 code, you're storing that via the access_token variable under DROPBOX_PREFS_SECRET.
In your API v2 code, you're storing that via the access_token variable under DROPBOX_PREFS_TOKEN.
(Part of the confusion may be that API v1 supported both OAuth 1 and OAuth 2. OAuth 1 access tokens are comprised of two pieces, a key and secret. API v2 only supports OAuth 2. OAuth 2 access tokens only have the one piece.)
- MateusP8 years agoHelpful | Level 6
Thanks dude, that worked! :grinning:
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,915 PostsLatest Activity: 5 hours agoIf 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!