Hi everyone,
I need some help as I’m really confused about how to proceed with Firebase authentication in my C# application.
I have successfully implemented authentication using IAM/Role with a service account in the "Editor" role. Here is an example of the code I’m using to authenticate and connect to Firestore:
var credential = GoogleCredential.FromJson(@"
{
""type"": ""service_account"",
""project_id"": ""example-project-id"",
""private_key_id"": ""example-private-key-id"",
""private_key"": ""-----BEGIN PRIVATE KEY-----\nEXAMPLE_PRIVATE_KEY\n-----END PRIVATE KEY-----\n"",
""client_email"": ""example-service-account@example-project-id.iam.gserviceaccount.com"",
""client_id"": ""example-client-id"",
""auth_uri"": ""https://accounts.google.com/o/oauth2/auth"",
""token_uri"": ""https://oauth2.googleapis.com/token"",
""auth_provider_x509_cert_url"": ""https://www.googleapis.com/oauth2/v1/certs"",
""client_x509_cert_url"": ""https://www.googleapis.com/robot/v1/metadata/x509/example-service-account@example-project-id.iam.gserviceaccount.com"",
""universe_domain"": ""googleapis.com""
}");
Using this method, my app can connect to Firestore and perform database queries and updates without issues.
However, I’m now trying to move to a production setup where I want to authenticate a user created in Firebase Authentication using an email and password. My goal is to provide a limited access to the database (after I will create the rules to Firestore) for this static user as the service account currently has too much accesses around, but I can’t figure out how to rewrite my code to achieve this.
How should I replace the current service account credentials with Firebase Authentication credentials (email and password) to allow a regular user to access Firestore with similar permissions? I have tried to create a custom service account with limited functions but its not well limited and plus cannot connect (for some reasons) to the database as Editor do....
Any guidance or examples would be greatly appreciated!
Thank you!