get key failed from google
Closed this issue ยท 3 comments
I just installed the most recent version 0.0.4 of the library and tested with my react-native sample project, it gave me this exception:
get key failed from google,
BTW, I can access this site: https://translate.google.com from my region.
So is the key expired? or I need to get my own key? or google changed their API again?
Thanks
If it's of any help:
You get different HTML bodies when you visit "https://translate.google.com". It seems to be random whether you get one that contains a match for tkk:'\d+.\d+'
.
When it comes to accessing the translate site through another TLD: I've been getting consistent HTML bodies that do not contain the match if visiting from the browser but the random behaviour happens when using a client like curl.
I tried doing multiple requests with various user agents and the results remain random which suggests that user agent has got nothing to do with this.
A solution may be to expose the key and api functions so that we can reuse valid keys in multiple requests, though I don't know for how long and for how many calls each key remains valid.
@moonstar-x The "get key failed" issue was temporarily fixed in the latest version 0.0.5 by add try mechanism.
If you are looking for reusing the token key, you might want to try this example.
https://github.com/zlargon/google-tts/blob/master/example/reuse-api-key.js