Forge Component
(10)
Published on 20 Jul (3 weeks ago) by João Almeida
10 votes
Published on 20 Jul (3 weeks ago) by João Almeida

How do I pass complex JSON objects to the custom claims? Could you share some sample?

Laxman Venkatesan wrote:

How do I pass complex JSON objects to the custom claims? Could you share some sample?

 Hi Laxman, you can't. The custom claims need to be in name/value pair format. One workaround could be serializing the complex object into JSON or base64, and add it as a custom claim.

 

Will the component be updated to support nested object in custom claim? Firebase accepts custom claims only as keys/values in 'claims' object claim.

https://firebase.google.com/docs/auth/admin/create-custom-tokens?hl=en#create_custom_tokens_using_a_third-party_jwt_library

Radoslaw Grabowski wrote:

Will the component be updated to support nested object in custom claim? Firebase accepts custom claims only as keys/values in 'claims' object claim.

https://firebase.google.com/docs/auth/admin/create-custom-tokens?hl=en#create_custom_tokens_using_a_third-party_jwt_library

Not in the roadmap for now, but if needed the workaround I mentioned above can be used. 

 

João Almeida wrote:

Radoslaw Grabowski wrote:

Will the component be updated to support nested object in custom claim? Firebase accepts custom claims only as keys/values in 'claims' object claim.

https://firebase.google.com/docs/auth/admin/create-custom-tokens?hl=en#create_custom_tokens_using_a_third-party_jwt_library

Not in the roadmap for now, but if needed the workaround I mentioned above can be used. 

 

I tried. How is it supposed to work if firebase requires nested object in the 'claims' claim and not the JSON string I can provide? I don't think it could work with some form of trying to escape the string but maybe I could have missed something.

I tried to provide custom claim without nesting in 'claims' claim but Firebase just ignores it. 

I tried to provide JSON with my custom claims(as you suggested to do) as the value for 'claims' claim but then Firebase rejects the request.

 

Radoslaw Grabowski wrote:

João Almeida wrote:

Radoslaw Grabowski wrote:

Will the component be updated to support nested object in custom claim? Firebase accepts custom claims only as keys/values in 'claims' object claim.

https://firebase.google.com/docs/auth/admin/create-custom-tokens?hl=en#create_custom_tokens_using_a_third-party_jwt_library

Not in the roadmap for now, but if needed the workaround I mentioned above can be used. 

 

I tried. How is it supposed to work if firebase requires nested object in the 'claims' claim and not the JSON string I can provide? I don't think it could work with some form of trying to escape the string but maybe I could have missed something.

I tried to provide custom claim without nesting in 'claims' claim but Firebase just ignores it. 

I tried to provide JSON with my custom claims(as you suggested to do) as the value for 'claims' claim but then Firebase rejects the request.

 

In that case I'm afraid there's no workaround, right now the component only supports the claims as a list of name value pairs.