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
MarioEM
8 years agoHelpful | Level 6
Auth2 Authentication check
I would like to be able to check if Dropbox authentication was successful.
In the old API v1, it was possible to run the following code:
AndroidAuthSession session = dropboxApi.getSession();
if (session.authenticationSuccessful()) {
try {
// Mandatory call to complete the auth
session.finishAuthentication();
storeAuth(session);
} catch (IllegalStateException e) {
cs = "Could not authenticate with Dropbox:" + e.getLocalizedMessage();
...
}
}
What would be the equivalent method in API v2 when running the following code:
Auth.startOAuth2Authentication(this, APP_KEY);
Also, is it possible to check if the following call was successful:
DropboxClientFactory.init(accessToken);
Using the API v2 Java SDK on Android, you can check if the app authorization was approved and get the access token using getOAuth2Token as shown here. It will return null if not.
The DropboxClientFactory.init method just builds a local client object, using whatever access token you give it, so you don't need to check for success. You can see it used here.
If you want to check that your access token is still valid, you need to make any actual API call, such as getCurrentAccount.
- MarkSuper User II*moves to API forum*
- Greg-DBDropbox Staff
Using the API v2 Java SDK on Android, you can check if the app authorization was approved and get the access token using getOAuth2Token as shown here. It will return null if not.
The DropboxClientFactory.init method just builds a local client object, using whatever access token you give it, so you don't need to check for success. You can see it used here.
If you want to check that your access token is still valid, you need to make any actual API call, such as getCurrentAccount.
- MarioEMHelpful | Level 6
Thank you Greg for the clarification. I was already doing that in code, as suggested, but I thought there was possibly another way to immediately check authentication.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,917 PostsLatest Activity: 31 minutes ago
If 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!