getUserProfile method

Future<MyAccountProfile> getUserProfile({
  1. List<String>? fields,
  2. bool includeFields = true,
})

Retrieves the current user's profile, including a MyAccountProfile.profilePolicy descriptor for each field that tells whether it can be edited by the user and why.

Pass fields to choose which fields are returned, e.g. ['given_name', 'picture', 'profile_policy']. With includeFields true (the default) only the listed fields are returned; with false every field except the listed ones is returned. includeFields is ignored when fields is null or empty.

MyAccountProfile.profilePolicy is null whenever profile_policy is not part of the response: when fields is set and does not list it, or when it is listed with includeFields false.

Availability

This feature is currently in Beta. It might change before General Availability, and Auth0 does not support beta functionality for production use. The feature must be enabled for your tenant.

Requires auth0-spa-js v2.30.0 or later, and an access token with the read:me:profile scope and audience https://{domain}/me/. A MyAccountException with status code 403 means the token lacks the scope or the feature is not enabled for the tenant.

Usage example

final profile = await myAccount.getUserProfile();
final canEditGivenName = profile.profilePolicy?['/given_name']?.access ==
    ProfileFieldAccess.readWrite;

Implementation

Future<MyAccountProfile> getUserProfile({
  List<String>? fields,
  bool includeFields = true,
}) =>
    Auth0FlutterWebPlatform.instance.getUserProfile(
        MyAccountGetUserProfileOptions(
            accessToken: _accessToken,
            fields: fields,
            includeFields: includeFields));