We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

didouchk's avatar
didouchk
Explorer | Level 3
3 years ago

Why Auth.getDbxCredential method returns null after PKCE authentication (Dropbox Android JDK) ?

Hi,

 

I'm trying to use the new authentication flow with short-live tokens and refresh tokens on  an Android App with Dropbox JDK.

I'm using the 

Auth.startOAuth2PKCE()

method which works correctly, but when I tried to access the credentials in the onResume method,

DbxCredential credential = Auth.getDbxCredential();
credential.getRefreshToken(); // NullPointerException

 I get a NullPointer exception.

 

I'd like to access and save the refresh token to the shared prefs and resuse it to prevent the user to be logged out every 4 hours.

Why the getDbxCredential() returns null ?

Thanks for your help.

 

  • didouchk In addition to what Здравко said, note that there is an Android-specific example here. Make sure you're implementing the authorization flow as shown.

     

    And if something doesn't seem to be working as expected, please reply with:

    • the version numbers of the Android platform and Dropbox SDK you are using
    • the steps to reproduce the issue, including relevant code snippet(s), but don't include any access or refresh token(s)
    • the full text of any error or unexpected output
  • Здравко's avatar
    Здравко
    Legendary | Level 20

    Hi didouchk,

    The description of your issue is not very "rich". Missing details on how you have done everything! The devil is in details. 😁

    There is an authorization example for Java SDK. PKCE implementation could be seen in corresponding class. Take a look there and you can figure out what's missing in your code, I believe. 😉

    Hope this helps.

     


    didouchk wrote:

    ..., but when I tried to access the credentials in the onResume method, ...


    You are trying in onResume method, but is it as a result of real resume action (i.e. on authentication end)? 🤔 ... or ...?

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    didouchk In addition to what Здравко said, note that there is an Android-specific example here. Make sure you're implementing the authorization flow as shown.

     

    And if something doesn't seem to be working as expected, please reply with:

    • the version numbers of the Android platform and Dropbox SDK you are using
    • the steps to reproduce the issue, including relevant code snippet(s), but don't include any access or refresh token(s)
    • the full text of any error or unexpected output
    • PIXIP's avatar
      PIXIP
      Explorer | Level 4

      I'm just pointing out that ALL the links here are broken since the repository changed on GitHub

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,877 PostsLatest Activity: 7 hours ago
325 Following

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

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!