I am trying to connect my Android 4+ to Dropbox. I am using the latest version of the Core API provided by Dropbox.
Everything works fine until I try to save the user key and token when the user returns to my app after he authenticated the access using dropboxAPI.getSession().startOAuth2Authentication(activity).
When the user returns to my app after the authentication the following code should save key and token:
public boolean completeLogInAfterAuthentication() {
AndroidAuthSession session = dropboxAPI.getSession();
if (session.authenticationSuccessful()) {
try {
// Mandatory call to complete the auth
session.finishAuthentication();
// Store it locally in our app for later use
TokenPair tokens = session.getAccessTokenPair();
saveSessionKeys(tokens.key, tokens.secret);
return true;
} catch (IllegalStateExceptione) {
Log.d("MyLog", "Couldn't authenticate with Dropbox:" + e.getLocalizedMessage());
Log.d("MyLog", "Error authenticating", e);
}
}
return false;
}
This is quite exactly the code that is used in the DBRoulett Demo provided by Dropbox. Problem is, that session.getAccessTokenPair() returns null.
Because of this I cannot store any key or token and the user has to re-login everytime the app is started. How can I solve this?
All information I found just say, that getAccessTokenPair() could fail with an IllegalStateException but this is not the case here. The case that null is returned is not described anywhere. Any idea what I can do?