google-translate-api
google-translate-api copied to clipboard
Response code 403 (Forbidden)
I recently began receiving 403 errors when using google-translate-api
. Digging in to the source a bit, this is the error that is being thrown:
{
"message": "Response code 403 (Forbidden)",
"host": "translate.google.com",
"hostname": "translate.google.com",
"method": "GET",
"path": "/translate_a/single?client=t&sl=en&tl=fr&hl=fr&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&otf=1&ssel=0&tsel=0&kc=7&q=A-Z%20Site%20Index&tk=801225.801225",
"statusCode": 403,
"statusMessage": "Forbidden"
}
Based on this comment, it seems that Google may have added in some rate limiting that may affect this module. Can you verify if this is the root cause?
I changed the line 35 to client: 'gtx',
instead of client: 't',
and it's working for me now.
@snowcxt - you're right, that change worked for me as well. Do you know why this fixes the issue?
I was also getting 403 but for another reason. It was caused by getting incorrect token in dependency module google-translate-token, see #12 (there is already working pr).
The url above also has incorrect token: ...&tk=801225.801225
(notice equal numbers around dot).
Now the most interesting part.
By the comments it looks like changing client
from gtx
to t
allows it to work with incorrect token.
I've tried the url with client=gtx
and got captcha. When I passed captcha, the translation was dowloaded.
So for client=gtx
token is not checked. I've tried url without token and it worked.
So, what's the best practice? Will somebody fix this bug?
So, what's the best practice? Will somebody fix this bug?
I forked google-translate-api and google-translate-token and made it work.
You can try by installing:
npm i vitalets/google-translate-api
UPDATE: Published to npm as @vitalets/google-translate-api:
npm i @vitalets/google-translate-api
See also https://github.com/matheuss/google-translate-api/issues/79#issuecomment-443428475
Worked!
Could you publish it to npm? @vitalets
Could you publish it to npm? @vitalets
I can make a scoped package, but frankly speaking I'm not a fan of many similar packages in npm.
Hi @matheuss, could you kindly have a look on https://github.com/matheuss/google-translate-token/issues/12 and merge it? As it blocks the functionality of both packages. Thanks in advance!
I have the same issue, using @snowcxt's solution worked for me.
So, we don't need the google-translate-token at all?
So, what's the best practice? Will somebody fix this bug?
I forked google-translate-api and google-translate-token and made it work.
You can try by installing:
npm i vitalets/google-translate-api
Ah God, finally worked! 🤦♂️
I changed the line 35 to
client: 'gtx',
instead ofclient: 't',
and it's working for me now.
This is the solution to described problem. Hooray this guy @snowcxt .
I changed the line 35 to
client: 'gtx',
instead ofclient: 't',
and it's working for me now.
Thanks a lot. You saved me. Just not sure how long will this trick work... How did you find this btw?
unfortunately, still not work...
@vitalets your solution is no longer working for me. I forked google-translate-api as well and edited index.js line 35 as suggested, from client: 't',
to client: 'gtx',
. That did the trick.
Hopefully the npm package will be fixed soon, but until then if you want you can just add "google-translate-api": "AlooAkbar/google-translate-api",
to your package.json
@snowcxt thanks. Changing client
from client: 't'
to client: 'gtx'
did the trick. Is there any way to get the term pronunciation (in the target language) as well?
@vitalets i rewrited your token repo in typescript and only replaced got
with fetch
and configstore
with its electron alternative nothing more but i got an incorrect token again {name: "tk", value: "38379.38379"}
.
@P0oOOOo0YA I will re-check. Thanks!
I've published to npm working scoped package @vitalets/google-translate-api:
npm install @vitalets/google-translate-api
After install don't forget to use scope in require
:
-- const translate = require('google-translate-api');
++ const translate = require('@vitalets/google-translate-api');
Also I've added client
parameter to be able to set client: 'gtx'
instead of client: 't'
:
const translate = require('@vitalets/google-translate-api');
translate('Ik spreek Engels', { client: 'gtx', to: 'en' })
.then(res => console.log(res.text)); // => "I speak English"
So, what's the best practice? Will somebody fix this bug?
I forked google-translate-api and google-translate-token and made it work.
You can try by installing:
npm i vitalets/google-translate-api
UPDATE: Published to npm as @vitalets/google-translate-api:
npm i @vitalets/google-translate-api
See also #79 (comment)
Also dont forget this https://github.com/matheuss/google-translate-api/issues/79#issuecomment-443428475
So, what's the best practice? Will somebody fix this bug?
I forked google-translate-api and google-translate-token and made it work.
You can try by installing:
npm i vitalets/google-translate-api
UPDATE: Published to npm as @vitalets/google-translate-api:
npm i @vitalets/google-translate-api
See also #79 (comment)
amazing ~ What did you do?
well good,it work well.
Getting HTTPError: Response code 429 (Too Many Requests)
after just one run on all languages.
gtx no longer functions correctly.
After looking at it it seems to be a way for Google Translate Plugin to receive translations without creating a token. Thus it was never meant to be used for many translations. Vitalets as well as matheuss's forks are creating incorrect tokens which is seriously affecting functionality.
Could a team be brought together to fix such errors who know how to work with this? I would be of limited help but I do want to help, this would be a huge help.
Could you publish it to npm? @vitalets
I can make a scoped package, but frankly speaking I'm not a fan of many similar packages in npm.
Hi @matheuss, could you kindly have a look on matheuss/google-translate-token#12 and merge it? As it blocks the functionality of both packages. Thanks in advance!
gtx no longer functions correctly.
After looking at it it seems to be a way for Google Translate Plugin to receive translations without creating a token. Thus it was never meant to be used for many translations. Vitalets as well as matheuss's forks are creating incorrect tokens which is seriously affecting functionality.
Could a team be brought together to fix such errors who know how to work with this? I would be of limited help but I do want to help, this would be a huge help.
I've released @vitalets/google-translate-api v5.0.0 that fixes the problem. PR with changes: #60, many thanks to @vkedwardli
client: 'gtx'
line 35 in which file?