Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth.getOAuth2Token() returns null #248

Open
ufumerfarooq opened this issue Apr 22, 2019 · 10 comments
Open

Auth.getOAuth2Token() returns null #248

ufumerfarooq opened this issue Apr 22, 2019 · 10 comments

Comments

@ufumerfarooq
Copy link

ufumerfarooq commented Apr 22, 2019

I am using dropbox-sdk-java v2 for android. If I try to authenticate the flow from browser, I always get NULL. Issues related to this kind of question are #71 and #161 and they are already closed but none helpful.
My manifest looks like:
android:name="com.dropbox.core.android.AuthActivity"
android:configChanges="orientation|keyboard"
android:screenOrientation="portrait"
android:launchMode="singleTask"
<intent-filter>
<data android:scheme="db-XXXXXXXXXXXXX"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

@greg-db
Copy link
Contributor

greg-db commented Apr 22, 2019

Have you implemented the app authorization flow as shown in the example Android app included with the SDK?:

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

You should refer to that as an example of how to implement the app authorization flow, which is accomplished via OAuth 2.

Your AndroidManifest.xml should be set up as shown here:

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/AndroidManifest.xml#L33

Specifically, you start the flow by calling startOAuth2Authentication as shown here:

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/UserActivity.java#L35 

You complete the flow by calling getOAuth2Token in onResume as shown here:

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/DropboxActivity.java#L22

Your app can store and re-use the resulting access token for that user, as the example does here:

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/DropboxActivity.java#L24

If that's not working for you, please share the steps and specific code to reproduce the issue.

@ufumerfarooq6
Copy link

The problem is with Firefox Android Browser. later I tried the authorization process on Chrome Android browser and it worked perfectly.
So if it worked for chrome then why not on firefox?

@greg-db
Copy link
Contributor

greg-db commented Apr 24, 2019

I just tried the authorization flow in the sample app using Firefox to authorize the app and it worked correctly for me.

If something isn't working as expected for you, please share:

  • the steps to reproduce the issue, including relevant code
  • any error/unexpected output you get
  • the version number(s) of Android you're seeing this with
  • the version number(s) of the Dropbox SDK you're seeing this with
  • the version number(s) of Firefox you're seeing this with

@jiuyangzhao
Copy link
Contributor

I suspect your case is related to #242

@songtoanht
Copy link

songtoanht commented Apr 6, 2020

@greg-db : I have a token and save shareprefences. After long time I open app again, I upload file with token in shareprefences, but I get error message "invalid_token". I want to ask you: in this sdk, do you have function refresh new token??? Please answer my question. Thank you

@greg-db
Copy link
Contributor

greg-db commented Apr 6, 2020

@songtoanht The public Dropbox API doesn't currently use refresh tokens, but Dropbox API access tokens can be revoked at any time by the user or app. If an access token does get revoked, you'd need to throw it away and prompt the user to re-authorize your app if they wish to continue using it.

This is issue thread is old and seems to be for a different issue than what you're referring to, so if something isn't working as expected, please open a new issue.

@songtoanht
Copy link

@greg-db Thank you so much. I want to confirm this issue. Because I saw many sdk to used refresh token to make behavior smoothly for the user. Thank you again

@abingvw
Copy link

abingvw commented Sep 12, 2022

Have you implemented the app authorization flow as shown in the example Android app included with the SDK?:

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

You should refer to that as an example of how to implement the app authorization flow, which is accomplished via OAuth 2.

Your AndroidManifest.xml should be set up as shown here:

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/AndroidManifest.xml#L33

Specifically, you start the flow by calling startOAuth2Authentication as shown here:

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/UserActivity.java#L35 

You complete the flow by calling getOAuth2Token in onResume as shown here:

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/DropboxActivity.java#L22

Your app can store and re-use the resulting access token for that user, as the example does here:

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/DropboxActivity.java#L24

If that's not working for you, please share the steps and specific code to reproduce the issue.

Hi greg, i'm not quite familiar with kotlin, can you provide once more android java version ?

@abingvw
Copy link

abingvw commented Sep 12, 2022

fully noted, and thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants