Hasan Teoman Tıngır
Hasan Teoman Tıngır

Reputation: 2901

API key not valid. error using google translate api

I was trying to translate couple words using api but, response keep saying me that api is not valid. I installed api file from google, and used "private_key"

api file

{
  "type": "service_account",
  "project_id": "foo-246510",
  "private_key_id": "10101010101",
  "private_key": "-----BEGIN PRIVATE KEY-----
something something-----END PRIVATE KEY-----",
  "client_email": "sample_email@com",
  ....
}

I use "something something" section between begin and end section. Did I wrong ? How we should use it ?

Upvotes: 0

Views: 1135

Answers (1)

F10
F10

Reputation: 2893

Based on the API file content, I understand you created a service account. According to the documentation, you need to set an environment variable named GOOGLE_APPLICATION_CREDENTIALS and set it according to your OS by replacing [PATH] with the path file of your service account JSON file.

For instance: For Linux or macOS:

export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"

For windows and powershell:

$env:GOOGLE_APPLICATION_CREDENTIALS="[PATH]"

For windows and command prompt:

set GOOGLE_APPLICATION_CREDENTIALS=[PATH]

Upvotes: 1

Related Questions