Error when app check is enforced FirebaseFirestoreException: PERMISSION_DENIED

Condition : Trying to connect to cloud Firestore with app check enabled.

Error : documents.com.google.firebase.firestore.FirebaseFirestoreException: PERMISSION_DENIED: Missing or insufficient permissions.

We are getting null APP check token after a specific interval of time when app check is enforced in Firebase. Testing is done from release Apk and debug Apk. App is not pushed to Play store yet. Can someone help in understanding why this is happening ?

0 2 2,309
2 REPLIES 2

Hi @Leaf,

Welcome to Google Cloud Community!

The error message suggests that the user does not have sufficient permissions to access Firestore due to App Check integration. It's possible that the user's device is not generating a valid App Check token, which could be caused by network connectivity issues or a misconfiguration in the Firebase project. To troubleshoot this issue, you can check your App Check configuration, verify that the app is generating App Check tokens correctly, and ensure that the user's device can connect to the internet. If none of these steps resolve the issue, you can reach out to Google Cloud Support for further assistance.

You may also want to check these documentations:

Thanks

 
 

The error "FirebaseFirestoreException: PERMISSION_DENIED: Missing or insufficient permissions" with a null App Check token when enforced could have several causes. Here are some steps to troubleshoot and understand the issue:

1. Verify App Check Setup:

Double-check your code: Ensure you're properly initializing App Check in your application and attaching the token to every Firestore request. Refer to the official documentation for your programming language,

Inspect debug logs: Check your app's logs for any App Check-related errors or warnings. These might indicate configuration issues or token retrieval problems.

Confirm Firebase project connection: Verify that your App Check configuration in Firebase Console matches your project and app settings.

2. Token Expiration and Refresh:

Understand token lifespans: App Check tokens have limited lifespans (usually 60 minutes). Ensure your app refreshes the token before it expires using the provided mechanisms in your chosen language.

Check token refresh logic: Analyze your code responsible for refreshing the token. Look for potential bugs or delays that might lead to a null token during Firestore access.