cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right 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: 

Auth2 Authentication check

Auth2 Authentication check

MarioEM
Helpful | Level 6
Go to solution

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);
1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

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.

View solution in original post

3 Replies 3

Mark
Super User II
Go to solution
*moves to API forum*

 


:penguin::penguin: - :penguin: - :penguin: - :penguin:


Heart Did this post help you? If so please mark it for some Kudos below. 


:white_check_mark: Did this post fix your issue/answer your question? If so please press the 'Accept as Solution' button to help others find it.


:arrows_counterclockwise: Did this post not resolve your issue? If so please give us some more information so we can try and help - please remember we cannot see over your shoulder so be as descriptive as possible! 


 

Greg-DB
Dropbox Staff
Go to solution

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.

MarioEM
Helpful | Level 6
Go to solution

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.

 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    MarioEM Helpful | Level 6
  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Mark Super User II
What do Dropbox user levels mean?