Skip to content

[plugins/firebase_auth] [plugins/cloud_firestore] custom claims not propagated on Android with user.getIdToken(refresh: true) #22801

@pboos

Description

@pboos

According to https://firebase.google.com/docs/auth/admin/custom-claims#propagate_custom_claims_to_the_client one can update the claims locally by calling currentUser.getIdToken(true).

In flutter I guess one should be able to do the same with:

final user = await FirebaseAuth.instance.currentUser();
await user.getIdToken(refresh: true);

Sadly this seems not reflected when I try to use firestore. After updating claims through a cloud function and then calling getIdToken as above it will still not have the claims correct in firestore rules. It returns "PERMISSION_DENIED". When I then close the app and reopen the app, firestore rules go through correctly though (seems like claims then get updated).

Additional problem is, that I can not see if the claims locally got updated or not because the API for that is not yet implemented (see separate issue #20238).

Now the issue is: How can force propagation of the claims in flutter? The way the documentation says seems not to be correct. Is this a bug in the documentation or a bug in the flutter client?

flutter: v0.8.2
cloud_firestore: 0.8.1
firebase_auth: 0.5.20

Edit

After further investigations it seems to only be happening on Android. On iOS the claims seem to be updated nicely (seems to work even without calling getIdToken() ). So this problem seems Android specific.

Metadata

Metadata

Assignees

No one assigned

    Labels

    p: cloud_firestoreFirebase Firestore pluginp: firebaseFirebase pluginsp: firebase_authThe Firebase Auth pluginpackageflutter/packages repository. See also p: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions