Skip to content

Auth.getOAuth2Token() returns null #248

Description

@umerfarooq492

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>

Activity

  1. greg-db commented on Apr 22, 2019

    @greg-db
    Contributor

    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.

  2. ufumerfarooq6 commented on Apr 24, 2019

    @ufumerfarooq6

    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?

  3. greg-db commented on Apr 24, 2019

    @greg-db
    Contributor

    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
  4. jiuyangzhao commented on May 12, 2019

    @jiuyangzhao
    Contributor

    I suspect your case is related to #242

  5. songtoanht commented on Apr 6, 2020

    @songtoanht

    @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

  6. greg-db commented on Apr 6, 2020

    @greg-db
    Contributor

    @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.

  7. songtoanht commented on Apr 6, 2020

    @songtoanht

    @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

  8. abingvw commented on Sep 12, 2022

    @abingvw

    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 ?

  9. abingvw commented on Sep 12, 2022

    @abingvw

    fully noted, and thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions