Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response code 403 (Forbidden) #79

Open
nfriend opened this issue Sep 29, 2018 · 26 comments · May be fixed by #87
Open

Response code 403 (Forbidden) #79

nfriend opened this issue Sep 29, 2018 · 26 comments · May be fixed by #87

Comments

@nfriend
Copy link

nfriend commented Sep 29, 2018

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?

@snowcxt
Copy link

snowcxt commented Sep 29, 2018

I changed the line 35 to client: 'gtx', instead of client: 't', and it's working for me now.

@nfriend
Copy link
Author

nfriend commented Sep 29, 2018

@snowcxt - you're right, that change worked for me as well. Do you know why this fixes the issue?

@vitalets
Copy link

vitalets commented Oct 1, 2018

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.

@snowcxt
Copy link

snowcxt commented Oct 8, 2018

So, what's the best practice? Will somebody fix this bug?

@vitalets
Copy link

vitalets commented Oct 8, 2018

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)

@Fausto95
Copy link

Fausto95 commented Oct 9, 2018

Worked!

@Fausto95
Copy link

Fausto95 commented Oct 9, 2018

Could you publish it to npm? @vitalets

@vitalets
Copy link

vitalets commented Oct 9, 2018

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!

@BirkhoffLee
Copy link

I have the same issue, using @snowcxt's solution worked for me.

@snowcxt
Copy link

snowcxt commented Oct 12, 2018

So, we don't need the google-translate-token at all?

@sadra
Copy link

sadra commented Oct 26, 2018

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!   🤦‍♂️

@jochemstoel
Copy link

I changed the line 35 to client: 'gtx', instead of client: 't', and it's working for me now.

This is the solution to described problem. Hooray this guy @snowcxt .

AlooAkbar added a commit to AlooAkbar/C-3PO that referenced this issue Nov 7, 2018
Sources package from vitalets/google-translate-api as described in issue matheuss/google-translate-api#79
@songkeys
Copy link

I changed the line 35 to client: 'gtx', instead of client: '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?

@martin-matj
Copy link

unfortunately, still not work...

@AlooAkbar
Copy link

@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

@AlooAkbar AlooAkbar linked a pull request Nov 29, 2018 that will close this issue
@P0oOOOo0YA
Copy link

P0oOOOo0YA commented Nov 30, 2018

@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?

@P0oOOOo0YA
Copy link

@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"}.

@vitalets
Copy link

vitalets commented Dec 1, 2018

@P0oOOOo0YA I will re-check. Thanks!

@vitalets
Copy link

vitalets commented Dec 1, 2018

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"

@mohasin69
Copy link

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
#79 (comment)

@MazsLi
Copy link

MazsLi commented Mar 19, 2019

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?

@myfreax
Copy link

myfreax commented May 14, 2019

well good,it work well.

@ruscandino
Copy link

Getting HTTPError: Response code 429 (Too Many Requests) after just one run on all languages.

@ArtanisTheOne
Copy link

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!

@vitalets
Copy link

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

@amitdevadhe
Copy link

client: 'gtx'

line 35 in which file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.