RaniDevpr
RaniDevpr

Reputation: 410

Add default custom claims to firebase token

We are working on an application that uses firebase for authentication purposes. We implemented the authentication mechanism in our angular application and everything works fine. what we want now is to add custom claims to the JWT tokens generated once the user is authenticated. We know about the Admin SDK here:

https://firebase.google.com/docs/auth/admin/custom-claims

but this requires the addition of a web service. is there a way to configure firebase via the portal to add a default custom claim for all existing users and new users. what we want is to add an "id" field with random GUID. is it possible to use the Admin SDK to configure this behaviour once and for all?

Thanks in advance.

Upvotes: 2

Views: 1297

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599081

There is no way to add custom claims without using the Admin SDK. This requires that you run a script on a trusted environment, such as your development machine, a server you control, or Cloud Functions for Firebase. The latter is probably your best option if you want to do this regularly, and don't have your own server.

Upvotes: 1

Related Questions