❔ Google Api- PermissionDenied

Facing an access problem using the google Api NuGet:
`Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", _googleApiParams.CredentialsPath /path to JSON file/);
_translationClient = TranslationServiceClient.Create();

DetectLanguageRequest request = new()
{
Parent = "projects/my-project-name",
Content = "this is a detection test"
};
`Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", _googleApiParams.CredentialsPath /path to JSON file/);
_translationClient = TranslationServiceClient.Create();

DetectLanguageRequest request = new()
{
Parent = "projects/my-project-name",
Content = "this is a detection test"
};
My Error: the exception:
`Grpc.Core.RpcException: 'Status(StatusCode="PermissionDenied", Detail="Cloud IAM permission 'cloudtranslate.languageDetectionModels.predict' denied. ")
`Grpc.Core.RpcException: 'Status(StatusCode="PermissionDenied", Detail="Cloud IAM permission 'cloudtranslate.languageDetectionModels.predict' denied. ")
This python code works howerver:
`self.translate_client = translate.Client.from_service_account_json(self.google_api_credentials_json_path)
translated_text = self.translate_client.translate(values="this is a test", target_language=target_language,
`self.translate_client = translate.Client.from_service_account_json(self.google_api_credentials_json_path)
translated_text = self.translate_client.translate(values="this is a test", target_language=target_language,
Any Ideas for a fix?
11 Replies
jcotton42
jcotton422y ago
what do the docs say GOOGLE_APPLICATION_CREDENTIALS should be? it's probably supposed to be the actual creds not a path to JSON
antimatter8189
antimatter8189OP2y ago
The Json contains the creds
MODiX
MODiX2y ago
jcotton42#1663
it's probably supposed to be the actual creds not a path to JSON
Quoted by
<@!446416451230760990> from #Google Api- PermissionDenied (click here)
React with ❌ to remove this embed.
antimatter8189
antimatter8189OP2y ago
Stack Overflow
How to set the GOOGLE_APPLICATION_CREDENTIALS from Google Cloud Vis...
I am following this tutorial to use Google Vision API, but even configuring the authentication credentials I get the following error: System.InvalidOperationException: 'The Application Default
jcotton42
jcotton422y ago
idk then
antimatter8189
antimatter8189OP2y ago
Lol so im basically screwed?
jcotton42
jcotton422y ago
I don't know anything about GCP so I can't help you further someone else may be able to tho
antimatter8189
antimatter8189OP2y ago
Can you please perhaps tag relevant people? 😄
jcotton42
jcotton422y ago
I wouldn't know who's relevant Maybe try #devops-and-tools or #web? (just guessing tho)
antimatter8189
antimatter8189OP2y ago
Will do thank you
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?