Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase - how to set custom claim from the console [duplicate]

In my application I use firebase authentication and Google account as credentials provider. I would like to assign roles to users. In order to do it I would like to add custom claims to the authentication token a user gets during login. And here is my problem because I don't know how to add claims to existing user from the firebase console.

like image 641
Clyde Barrow Avatar asked Feb 11 '20 14:02

Clyde Barrow


1 Answers

There is currently no way to set custom claims for a user in the Firebase console. If you think this would be a useful addition, file a feature request for it.

In the meantime the easiest way to add a custom claim is to do so from the a terminal window/command prompt using a small Node.js script like this:

admin.auth().setCustomUserClaims(uid, {admin: true})

Also see:

  • How to create Firebase Authentication claims?
like image 123
Frank van Puffelen Avatar answered Sep 25 '22 00:09

Frank van Puffelen