Android User Profile

This tutorial will show you how to get and modify the user's profile data in your Android apps with Auth0.

Sample Project

Download a sample project specific to this tutorial configured with your Auth0 API Keys.

System Requirements
  • Android Studio 2.3
  • Android SDK 25
  • Emulator - Nexus 5X - Android 6.0
Show requirements

Before Starting

Be sure that you have completed the Login and the Session Handling Quickstarts. You'll need a valid access_token and id_token to call the API clients.

Request User Data

The first step is to instantiate the API clients. This will be used to request the user's profile data.

Auth0 auth0 = new Auth0("YOUR_CLIENT_ID", "YOUR_AUTH0_DOMAIN");

String idToken = CredentialsManager.getCredentials(this).getIdToken();
UsersAPIClient usersClient = new UsersAPIClient(auth0, idToken);
AuthenticationAPIClient authClient = new AuthenticationAPIClient(auth0);

It's suggested that you add both the Auth0 domain and clientId to the strings.xml file rather than hardcode them.

Next, use the access_token to obtain the user id with the AuthenticationAPIClient. Although the call returns a UserProfile instance, this is a basic OIDC conformant profile and the only value guaranteed to be present is the sub claim that indicates the user id. We're going to use this value to call later the Management API and get a full profile.

String accessToken = CredentialsManager.getCredentials(this).getAccessToken();
    .start(new BaseCallback<UserProfile, AuthenticationException>() {

        public void onSuccess(final UserProfile userInfo) {
            String userId = userInfo.getId();
            // fetch the full user profile

        public void onFailure(AuthenticationException error) {
            //show error

Finally, use the UsersAPIClient and the user id to get the full User profile.

        .start(new BaseCallback<UserProfile, ManagementException>() {
            public void onSuccess(UserProfile profile) {
                // Display the user profile

            public void onFailure(ManagementException error) {
                //show error

Access The Data Inside The UserProfile


At this point, you already have access to the UserProfile. You can use this data wherever you need it.

Some examples are:


Remember that you can't modify the UI inside the onSuccess() method, as it works in a second thread. To solve this, you can persist the data, create a task in the UI thread or create a handler to receive that information.


Besides the defaults, you can handle more information that is contained within any of the following map:


The userMetadata map contains fields related to the user profile that can be added from the client-side (e.g. when editing the profile). We're going to edit this one in this tutorial. You can access its fields as follows:

String country = (String) profile.getUserMetadata().get("country");

The strings you use for subscripting the user_metadata map, and the variable types you handle, are up to you.


The appMetadata map contains fields that are usually added via a Rule or Hook, which is read-only for the native platform.


The extraInfo map contains additional values stored in Auth0 but not mapped to a UserProfile getter method. That information is read-only for the native platform.

For further information on metadata, see the full documentation.

Update the User Profile

You can only update the user metadata. In order to do so you must create a Map<String, Object> and add the new metadata:

Map<String, Object> userMetadata = new HashMap<>();
userMetadata.put("country", "USA");

And then with the UsersAPIClient, perform the update:

String idToken = CredentialsManager.getCredentials(this).getIdToken();
UsersAPIClient usersClient = new UsersAPIClient(auth0, idToken);
usersClient.updateMetadata(userInfo.getId(), userMetadata).start(new BaseCallback<UserProfile, ManagementException>() {
  public void onSuccess(final UserProfile profile) {
    // As receive the updated profile here
    // You can react to this, and show the information to the user.

  public void onFailure(ManagementException error) {
    //show error
Previous Tutorial
3. Session Handling
Use Auth0 for FREECreate free Account