Problem setting the GOOGLE_APPLICATION_CREDENTIALS for my app

MrZabbah 21 Reputation points
2021-07-13T09:57:31.233+00:00

Hello! My problem is that when I try to set the GOOGLE_APPLICATION_CREDENTIALS environment variable, if I print the path it is correct. But when I try to create the instance of the Database and exception unhandled appears with the next message:
Error readind credential file from location X. Could not find a part of the path X. Please check the value of the environtment variable. But the value is correct and is set to the path of the private key of google project.

I set it on the app.xaml.cs on my base xamarin form project with Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "C:/Users/myuser/Downloads/projectname-319700-ae570902a804.json");

If I add it on the project properties debug, it does not recognize it. Also I tried to set it on my CMD and restarting visual, but it neither recognize it. If I use this last option the exception is: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials.

I'm trying to follow the next guide : https://cloud.google.com/docs/authentication/getting-started

I'm doing this to connect my app to a firebase firestore database

@Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.)

Developer technologies .NET Xamarin
Microsoft Security Microsoft Entra Microsoft Entra External ID
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.