firebasefirebase-authenticationfirebase-console

Firebase - how to set custom claim from the console


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.


Solution

  • 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})
    

    A alternative is to use this experimental (but working) Extension that synchronizes custom claims between Firestore documents and Authentication.

    Also see: