setCustomUserClaims method
Sets the custom claims of the user uid, which replace the previous ones; null or an empty map clears them.
The claims reach the ID tokens the user gets from now on (the client sees them after a token refresh), and
request.auth.token of the security rules. They are at most 1000 bytes of JSON and appear in every ID
token: no secrets, no large data.
Throws forbidden-claim for a reserved name (reservedClaims), claims-too-large over 1000 bytes,
invalid-claims for something that is not JSON, and user-not-found.
Implementation
Future<void> setCustomUserClaims(
String uid,
Map<String, Object?>? claims,
) async {
_checkOpen();
_checkUid(uid);
final String encoded = _checkUserClaims(
claims ?? const <String, Object?>{},
);
await _identityToolkit('accounts:update', <String, Object?>{
'localId': uid,
'customAttributes': encoded,
});
}