cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Access Token is invalid in android

Access Token is invalid in android

silent10
Explorer | Level 4

I am creating a OAuth2AccessToken and storing it in shared preferences. The session is successful till the app is closed. It is invalid after I open the app again. This is the code I am using to create a new session using the stored access token.

 

String dropboxaccesstoken = sharedpreferencessam.getString("dropboxaccesstoken", ""); // getting Boolean
Log.d("dropboxaccesstoken","token is: " + dropboxaccesstoken);
AppKeyPair appKeys = new AppKeyPair(APP_KEY, APP_SECRET);
AndroidAuthSession session = new AndroidAuthSession(appKeys,dropboxaccesstoken);
//session.setOAuth2AccessToken(dropboxaccesstoken);
mDBApi = new DropboxAPI<AndroidAuthSession>(session);
Log.d("(at successful or not", Boolean.toString((mDBApi.getSession().authenticationSuccessful())));

 
Logcat:

03-17 02:47:27.119 22706-23044/com.audiorecorder.wel.voicerecorder D/dropboxaccesstoken: token is: <ACCESS_TOKEN_REDACTED>
03-17 02:47:27.145 22706-23044/com.audiorecorder.wel.voicerecorder D/(at successful or not: false

Can someone help me on this please.

1 Accepted Solution

Accepted Solutions

Re: Access Token is invalid in android

Greg-DB
Dropboxer

 

 

The authenticationSuccessful is only meant for use during the actual app authorization flow, when the user chooses whether or not to authorize the app. That being the case, it will only return true during that first session.

 

If you just want to know if you have an access token, you should use isLinked.

 

By the way, I redacted it, but you publicly posted a valid access token, so for the sake of security, you should disable it. You can do so by revoking access to the app entirely, if the access token is for your account, on your account security page.

 

Or, you can disable just this access token using the API:

 

v1: https://www.dropbox.com/developers/core/docs#disable-token
v2: https://www.dropbox.com/developers/documentation/http/documentation#auth-token-revoke

 

Finally, I should note that the Android Core SDK you're using uses API v1, which is deprecated. You should migrate to API v2. You can use the API v2 Java SDK for that.

View solution in original post

3 Replies 3

Re: Access Token is invalid in android

Greg-DB
Dropboxer

 

 

The authenticationSuccessful is only meant for use during the actual app authorization flow, when the user chooses whether or not to authorize the app. That being the case, it will only return true during that first session.

 

If you just want to know if you have an access token, you should use isLinked.

 

By the way, I redacted it, but you publicly posted a valid access token, so for the sake of security, you should disable it. You can do so by revoking access to the app entirely, if the access token is for your account, on your account security page.

 

Or, you can disable just this access token using the API:

 

v1: https://www.dropbox.com/developers/core/docs#disable-token
v2: https://www.dropbox.com/developers/documentation/http/documentation#auth-token-revoke

 

Finally, I should note that the Android Core SDK you're using uses API v1, which is deprecated. You should migrate to API v2. You can use the API v2 Java SDK for that.

View solution in original post

Re: Access Token is invalid in android

silent10
Explorer | Level 4

Thanks, it solved my problem. There is no Android SDK for API v2?

Re: Access Token is invalid in android

Greg-DB
Dropboxer

You should use the API v2 Java SDK for Android. There's an Android example app that uses that for reference.

Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    silent10 Explorer | Level 4
What do Dropbox user levels mean?
Need more support?