Hi, is the custom-claims still usable in Firestore Rules ? It worked for me few months back, but same rule is not working now.
Getting error - Missing or insufficient permissions
Rule used:
allow read: if request.auth.token.level == 4
I have verified the user has the custom token claim. Printing tokens in console on UI, onAuthStateChanged shows the new token
level: "4"
JS code to print user custom claims in console log:
if(user) { user.getIdToken(true) .then(() => { user.getIdTokenResult().then(idTokenResult => { console.log('firebase-util.js idTokenResult.claims: ', idTokenResult.claims) }) }) } else { console.log('refreshIdTokens : currentUser not set') }
In firebase documentation also, I see only Database Rules and Storage Rules are mentioned for Custom-Claims. I do not see reference of Firestore Rules - firebase.google.com/docs/auth/admi...
Oh, got it sorted just now.
Issue: Custom claim (level) was String "4" Fix: Changed it to Number 4
Hi Pradeep-here! Great to know that everything worked :)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi, is the custom-claims still usable in Firestore Rules ?
It worked for me few months back, but same rule is not working now.
Getting error - Missing or insufficient permissions
Rule used:
I have verified the user has the custom token claim. Printing tokens in console on UI, onAuthStateChanged shows the new token
JS code to print user custom claims in console log:
In firebase documentation also, I see only Database Rules and Storage Rules are mentioned for Custom-Claims. I do not see reference of Firestore Rules - firebase.google.com/docs/auth/admi...
Oh, got it sorted just now.
Issue: Custom claim (level) was String "4"
Fix: Changed it to Number 4
Hi Pradeep-here! Great to know that everything worked :)