One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
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.
- Mark
Super User II
*moves to API forum* - Greg-DB
Dropbox 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,950 PostsLatest Activity: 2 hours 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!