Requirements
Android API version 21 or newer is required.Installation
Add the SDK into your project. The library will make requests to Auth0’s Authentication and Management APIs.Add Auth0 to Gradle
In your app’sbuild.gradle
dependencies section, add the following:
+
sign, or if you want to use a fixed version, check for the latest in Maven or JCenter.
Sync project with Gradle
Remember to synchronize using the Android Studio prompt or run
./gradlew clean build
from the command line. For more information about Gradle usage, check their official documentation.android
section, target Java 8 byte code for Android and Kotlin plugins respectively.
Permissions
Open your application’sAndroidManifest.xml
file and add the following permission.
Configure for Universal Login
First, go to Dashboard > Applications and click the name of the application you want to edit. In Allowed Callback URLs, make sure your URL follows this format:https://YOUR_DOMAIN/android/{YOUR_APP_PACKAGE_NAME}/callback
Next, replace {YOUR_APP_PACKAGE_NAME}
with your actual application’s package name. You can find this in your app/build.gradle
file as the applicationId
value.
Then, in your app/build.gradle
file, add the Manifest Placeholders for the Auth0 Domain and the Auth0 Scheme properties, which the library will use to register an intent-filter that captures the callback URI.
If you don’t plan to use the Web Authentication feature and not declare the manifest placeholders, you can manually redeclare the activity in your Android app’s manifest file to remove it from the merged manifest file. This will prevent Gradle from complaining that the manifest placeholders are missing.Please read the FAQ for more information.
It’s a good practice to define reusable resources like
@string/com_auth0_domain
rather than just hard-coding them.Initialize Auth0
Create a newAuth0
object using your Auth0 and domain value. Objects will later use this when interacting with Auth0’s endpoints.
Next steps
Log users in and out of your application using theWebAuthProvider
class.
Reset user password
To initiate a password reset for a user, callresetPassword
with the user’s email address and the database connection name as parameters.
Password reset requests will fail on network-related errors, but will not fail if the designated email does not exist in the database (for security reasons).