cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close

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: 
Highlighted

How to pass the "request code" when doing authentication

New member | Level 1
New member | Level 1

This is for Android: I am moving from Sync API to Core API. Once you do authentication, onResume is called. However, there is no request code to be passed so I can check it in the onResume. How would I know that the onResume is called due to "authentication flow" or due to simply the user is reopening the activity? I don't want to be continuing with the authentication and move files to dropbox if the user was simply opening my app. You see my point?

5 Replies 5
Highlighted

Re: How to pass the "request code" when doing authentication

Dropboxer
Dropboxer

The auth flow works a bit differently between the two SDKs. You can find instructions for setting up the auth flow in the Core SDK here:

https://www.dropbox.com/developers/core/start/android#authenticating

You use the authenticationSuccessful method to check if the user is coming back from the app auth flow. If not, it will return false so your app doesn't run the rest of that code again.

Highlighted

Re: How to pass the "request code" when doing authentication

New member | Level 1
New member | Level 1

Thank you Greg. Let me ask you about this scenario then. Let's say that in my app the user wants to backup a file. So the app initiates authentication, on resume is called and the file gets backed up. Good, now let's say right away the user press home button and come back to the app, the on resume will be called. In that case, won't the authenticationSuccessfull returns true? And if so then the file will get backup again (and the file could've changed meanwhile).
IIn summary, is it guaranteed that the authenticationSuccessfull will return true "only" if the on resume is called as a result Auth flow and will return false even if authentication was just done previously on the same activity?

Thank you again

Highlighted

Re: How to pass the "request code" when doing authentication

Dropboxer
Dropboxer

Your summary is correct, authenticationSuccessful only returns true right after the auth flow. Simply returning to the app normally won't have it return true.

Highlighted

Re: How to pass the "request code" when doing authentication

New member | Level 1
New member | Level 1

How to perform this check using API v2?

Highlighted

Re: How to pass the "request code" when doing authentication

Dropboxer
Dropboxer

Allek, are you using the Dropbox Java SDK for API v2 on Android? If so, there's a sample that shows the authorization flow here:

https://github.com/dropbox/dropbox-sdk-java/tree/master/examples/android

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?