Auth0.Android is a client-side library you can use with your Android app to authenticate users and access Auth0 APIs.
Android API version 15 or newer is required.
Auth0.Android is available through Gradle. To install it, simply add the following line to your
After adding your Gradle dependency, make sure to remember to sync your project with Gradle files.
Open your app's
AndroidManifest.xml file and add the following permission.
Save your application information in the
strings.xml file using the following names:
And then create your new Auth0 instance by passing an Android Context:
OIDC Conformant Mode
It is strongly encouraged that this SDK be used in OIDC Conformant mode. When this mode is enabled, it will force the SDK to use Auth0's current authentication methods and will prevent it from reaching legacy endpoints. By default is
Passwordless authentication cannot be used with this flag set to
true. For more information, please see the OIDC adoption guide.
Authentication via Universal Login
First go to the Dashboard and go to your application's settings. Make sure you have in Allowed Callback URLs a URL with the following format:
Then in your
app/build.gradle file add the Manifest Placeholders for the Auth0 Domain and the Auth0 Scheme properties which are going to be used internally by the library to register an intent-filter that captures the callback URI.
Alternatively, you can declare the
RedirectActivity in the
AndroidManifest.xml file with your own intent-filter so it overrides the library's default. If you do this then the Manifest Placeholders don't need to be set as long as the activity declaration contains the
Finally, don't forget to add the internet permission:
Now, let's authenticate a user by presenting the universal login page:
The authentication result will be delivered to the callback.
To ensure an Open ID Connect compliant response you must either set an
audience using withAudience or enable the OIDC Conformant switch in your Auth0 dashboard under Dashboard > Settings > Advanced > OAuth. You can read more about this in the documentation page on how to use new flows.
Using the Authentication API
The Authentication Application provides methods to accomplish authentication and related tasks. Create a new instance by passing in the Auth0 object created in the previous step.
Get user information
To get the information associated with a given user's Access Token, you can call the
userInfo endpoint, passing the token.
To initiate a password reset for a user, call
resetPassword with the user's email address and the database connection name as parameters.
Take a look at the following resources to see how the Auth0.Android SDK can be customized for your needs: