简体   繁体   中英

Google cloud translate API - “Daily Limit Exceeded”

I'm writing a bit of python using the google cloud api to translate some text.

I have set up billing on my account and it says it's active (with some credit added for the free trial). I created an application_default_credentials.json file with -

gcloud auth application-default login

Which asked me to log in to my account (I logged into the same account I set billing up on).

I then used -

os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/home/theo/.config/gcloud/application_default_credentials.json"

at the start of my python script. For the coding I followed these samples here - https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/translate/cloud-client

Yesterday the api wouldn't work and I would receive "daily limit exceeded" even though I had not used it yet. Eventually I gave up and decided to sleep on it.

Tried again today and it was working. Without having to do anything. Ah great I thought, it must just have taken a while to update my billing information.

But I've since translated a few things, maybe 10000 characters and I'm already receiving the same error message.

I did create a "Project" on the cloud console and have an api key from there. I'm not entirely sure how to use it because the documentation I linked above just uses the json credentials file. From what I've read online, using the json file is recommended over using a key now.

Any ideas about what I need to do?

Thanks.

Solved by creating a token at https://console.cloud.google.com/apis/credentials/serviceaccountkey instead of the one created with the gcloud auth command.

After I referenced the generated json file from that page it started working.

More info here - https://cloud.google.com/docs/authentication/getting-started

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM