Forum Discussion

Scott A.26's avatar
Scott A.26
New member | Level 1
10 years ago

How to know if authentication failed using Auth only in Android (Java SDK V2).

Hello, I just migrated my android application from the v1 android sdk. The migration went more or less smoothly. I did however run into a bit of an issue with authentication. My app interfaces with several different cloud providers, so it has a home screen/activity in which the user selects the provider to use. This then starts a new activity for the specific provider (ie Dropbox).

I have read that direct use of AuthActivity is now discouraged and developers should be using the new Auth helper class. The problem is that I need to know if the authentication failed so that I can finish the activity and return to the home screen. However, I cannot find a way to tell if authentication failed using the Auth class.

Every example I see, including the one from dropbox overrides 'onResume()' and attempts 'Auth.getOAuth2Token()'. This works fine in the examples because they have a button to sign into dropbox. In the event that authentication failed they can click the button to try again. In my case, the button is on the home activity, so the dropbox activity needs to close itself in the event of failure.

I have my app working perfectly using AuthActivity directly and 'onActivityResult()', but I was wondering if there was anyway to do this through the Auth class.

Thank you

TLDR; Can I check if the AuthActivity failed using only the Auth class?

2 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    10 years ago

    I don't believe there's much you can do with the Auth class beyond just checking if the getOAuth2Token method returns null. If using AuthActivity directly works better for your use case I think that would be fine to do.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

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, Facebook or Instagram.

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!