cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more 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: 

Re: 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
Go to solution

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

Greg-DB
Dropbox Staff
Go to solution

@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

4 Replies 4

Здравко
Legendary | Level 20
Go to solution

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
Dropbox Staff
Go to solution

@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
Explorer | Level 4
Go to solution

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

Greg-DB
Dropbox Staff
Go to solution

@PIXIP Thanks for the note. I've updated the links in my post.

Need more support?