Configure Auth0
Install the Auth0 Android SDK
Add manifest placeholders
intent-filter
, which captures the authentication callback URL. You must set Auth0 tenant domain and the callback URL scheme.You do not need to declare a specific intent-filter
for your activity, because you have defined the manifest placeholders with your Auth0 Domain and Scheme values and the library will handle the redirection for you.**bold**demo**bold**
for **bold**auth0Scheme**bold**
here, so that a custom URL scheme can be used for the URL that Auth0 redirects
to after login. Whenever possible, Auth0 recommends using Android App
Links with
**bold**https**bold**
as a secure way to link directly to content within
your app. Custom URL schemes can be subject to client impersonation
attacks. You can
read more about setting this value in the Auth0.Android SDK
readme.Configure your application
strings.xml
:com_auth0_domain
: The domain of your Auth0 tenant. Generally, you can find this in the Auth0 Dashboard under your Application’s Settings in the Domain field. If you are using a custom domain, you should set this to the value of your custom domain instead.
com_auth0_client_id
: The ID of the Auth0 Application you set up earlier in this quickstart. You can find this in the Auth0 Dashboard under your Application’s Settings in the Client ID field.
AndroidManifest.xml
file specifies the android.permissions.INTERNET
permission:./gradlew clean assembleDebug
from the command line.Add login to your application
onCreate
method, create a new instance of the Auth0
class to hold user credentials.Create a loginWithBrowser
method and use the WebAuthProvider
class to authenticate with any connection you enabled on your application in the Auth0 dashboard. Here, you can pass the scheme value that was used in the auth0Scheme
manifest placeholder as part of the initial configuration.After you call the WebAuthProvider#start
function, the browser launches and shows the login page. Once the user authenticates, the callback URL is called. The callback URL contains the final result of the authentication process.loginWithBrowser
. When you click it, verify that your Android application redirects you to the Auth0 Universal Login page and that you can now log in or sign up using a username and password or a social provider.Once that’s complete, verify that Auth0 redirects back to your app.com_auth0_domain
: The domain of your Auth0 tenant. Generally, you can find this in the Auth0 Dashboard under your Application’s Settings in the Domain field. If you are using a custom domain, you should set this to the value of your custom domain instead.com_auth0_client_id
: The ID of the Auth0 Application you set up earlier in this quickstart. You can find this in the Auth0 Dashboard under your Application’s Settings in the Client ID field.AndroidManifest.xml
file specifies the android.permissions.INTERNET
permission:./gradlew clean assembleDebug
from the command line.Add logout to your application
WebAuthProvider
to remove the cookie set by the browser at authentication time, so that the users are forced to re-enter their credentials the next time they try to authenticate.Add a logout
method to your app to remove the user’s session and log them out of the app. Here, you can pass the scheme value that was used in the auth0Scheme
manifest placeholder as part of the initial configuration.Use the WebAuthProvider
class to implement logout. This call opens the browser and navigates the user to the logout endpoint. If the user cancels the logout, consider redirected the user to their previous URL.logout
and logs the user out of your application. When you click it, verify that your Android app redirects you logout page and back again, and that you are no longer logged in to your application.Show user profile information
AuthenticationAPIClient
class to retrieve the user’s profile from Auth0. This requires:WebAuthProvider.login
must contain the profile
scopeemail
scope if you need to retrieve the user’s email address.openid profile email
scopes by default during the
login step above.showUserProfile
function after login. Verify the onSuccess
callback returns the user’s profile information.