Xamarin.forms trying to read from cloud firestore: missing or insufficient permissions

asked 2021-04-12T15:59:56.557+00:00
AspiringApollo 21 Reputation points

Having a problem reading a doc from a Cloud Firestore collection. The issue is I get an exception of ErrorType: PermissionDenied and this message "Missing or insufficient permissions."

nugets: FirebaseAuthentication.net(3.6.0) Plugin.CloudFirestore(4.1.0)

public async Task<IDocumentSnapshot> GetUserAndPopulate()
{
var doc = await CrossCloudFirestore.Current
.Instance
.Collection("users")
.Document(AccountManager.CurrentUserId)
.GetAsync();
return doc;
}
the CurrentUserId is populated after sign and is correct. Each document in the users collection has a document ID of the userID in Cloud Firestore.

Below are the security rules for read and write access to the documents in users collection.

rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{user_id}{
allow read, write: if request.auth != null && request.auth.uid == user_id;
}
}
}
I know that the request is being seen as not authenticated but I really don't know why?

Any Advice would be greatly appreciated.

Thanks!

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
4,803 questions
No comments
{count} votes