Android Dropbox AccessToken

817 Views Asked by At

I have my access token, how do I hard-code it into the app? I am trying to use this but I need 2 tokens(??) on accesstokenpair but there is only one? I am confused, I know you shouldnt hard-code but I am developing the app for personal purpose

AppKeyPair appKeys = new AppKeyPair(APP_KEY, APP_SECRET);
AccessTokenPair accessTokenPair = new AccessTokenPair("XXXXXX");
AndroidAuthSession session = AndroidAuthSession(AppKeyPair appKeys, AccessTokenPair accessTokenPair)
mDBApi = new DropboxAPI<AndroidAuthSession>(session);
1

There are 1 best solutions below

0
On BEST ANSWER

The code you posted is for the Dropbox Android Core SDK, and the AndroidAuthSession constructor you're using is meant for OAuth 1 access tokens, but it sounds like you have an OAuth 2 access token.

For reference, the Dropbox API currently supports both OAuth 1 and OAuth 2. Access tokens for OAuth 1 have two pieces (key and secret) and access tokens for OAuth 2 have just one piece.

To get an AndroidAuthSession using an OAuth 2 access token, you can instead use this constructor, passing in the access token as a string, instead of AccessTokenPair:

https://www.dropboxstatic.com/static/developers/dropbox-android-sdk-1.6.3-docs/com/dropbox/client2/android/AndroidAuthSession.html#AndroidAuthSession(com.dropbox.client2.session.AppKeyPair,%20java.lang.String)