cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Get summer ready with Dropbox basic - travel documents, plans, progress reminders and more, right over here.

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: 

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

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

didouchk
Explorer | Level 3

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.

 

1 Accepted Solution

Accepted Solutions

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

Greg-DB
Dropboxer

@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

View solution in original post

2 Replies 2

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

Здравко
Super Collaborator | 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 ...?

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

Greg-DB
Dropboxer

@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
Poll
Which Dropbox Plan do you have?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    Здравко Super Collaborator | Level 20
What do Dropbox user levels mean?
Need more support?