setCustomUserClaims method

Future<void> setCustomUserClaims(
  1. String uid, {
  2. Map<String, Object?>? customUserClaims,
})
inherited

Sets additional developer claims on an existing user identified by the provided uid, typically used to define user roles and levels of access. These claims should propagate to all devices where the user is already signed in (after token expiration or when token refresh is forced) and the next time the user signs in. If a reserved OIDC claim name is used (sub, iat, iss, etc), an error is thrown. They are set on the authenticated user's ID token JWT.

See https://firebase.google.com/docs/auth/admin/custom-claims for code samples and detailed documentation.

  • uid - The uid of the user to edit.
  • customUserClaims - The developer claims to set. If null is passed, existing custom claims are deleted. Passing a custom claims payload larger than 1000 bytes will throw an error. Custom claims are added to the user's ID token which is transmitted on every authenticated request. For profile non-access related user attributes, use database or other separate storage systems.

Implementation

Future<void> setCustomUserClaims(
  String uid, {
  Map<String, Object?>? customUserClaims,
}) async {
  await _authRequestHandler.setCustomUserClaims(uid, customUserClaims);
}