简体   繁体   中英

Android Dropbox AccessToken

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);

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM