"No Credentials were Previously Set" Error with Android SDK

Overview

This article addresses an error that occurs in Auth0 applications on Android. The following error message is displayed:

No Credentials were previously set.

Applies To

Cause

This error occurs when no valid credentials are stored in the CredentialsManager.

Solution

Use the hasValidCredentials method before calling the getCredentials method in the implementation.

  • If hasValidCredentials() returns true, credentials exist. Call getCredentials() to fetch and use them (for example, to make an API call).

  • If hasValidCredentials() returns false, the user is not logged in. Do not call getCredentials(), as it will fail or return null. Direct the user to the login page.

NOTE: The hasValidCredentials() method does not check if the Access Token is expired; it only checks if credentials exist in storage. The logic flow after calling getCredentials() must include an expiration check. If the token is expired, use the Refresh Token (part of the credentials object) to get a new Access Token. 

NOTE: A call to clearCredentials followed by a call to getCredentials will also reproduce this error.

Recommended content

No recommended content found...