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

Always getting 403 error #22

Open
funkyremi opened this issue Nov 10, 2020 · 21 comments
Open

Always getting 403 error #22

funkyremi opened this issue Nov 10, 2020 · 21 comments

Comments

@funkyremi
Copy link

Hello
It seems that almost all request end up with error code 403.

@lvsenlin
Copy link

好像是限制4秒一次请求

@leohxj
Copy link

leohxj commented Nov 17, 2020

感觉没用几次就 403 了

@hua1995116
Copy link
Owner

Duplicates to matheuss/google-translate-api#79.
I used "t" instead of "webapp" in version 1.3.7

@leohxj
Copy link

leohxj commented Nov 17, 2020

@hua1995116
sorry, which option? It seems no client params.

@leohxj
Copy link

leohxj commented Nov 17, 2020

I set client with "t" or "webapp" , but also got 403....

@hua1995116
Copy link
Owner

What about usingclient:'gtx? I saw that the original answer also mentioned this solution. In my local, after I useclient:"t, the frequency of 403 is significantly reduced. This is related to Google's restrictions...There is currently no particularly good way.

@leohxj
Copy link

leohxj commented Nov 17, 2020

Unfortunately, it also doesn't work.
Do you have any other free api recommend?

@Denny966
Copy link

Got the same issue

@guomh
Copy link

guomh commented Dec 2, 2020

same problem

@McDaddy
Copy link

McDaddy commented Dec 4, 2020

碰到同样问题, 有解决方法么?

@uumom
Copy link

uumom commented Dec 4, 2020

The same issue, is there any solution?

@hua1995116
Copy link
Owner

It seems that Google has changed the way it generates tokens for bulk generation, and no good alternative has been found yet.

@ListeH
Copy link

ListeH commented Dec 20, 2020

Hope it will be resolved soon 😕

@gd4Ark
Copy link

gd4Ark commented Dec 23, 2020

升级到 1.3.7,依然 403🥵

@ValentinRLL
Copy link

still 403 here! :(

@felipemarinho97
Copy link

@hua1995116 take a look here vitalets/google-translate-api#61

@leizelong
Copy link

use client: "dict-chrome-ex" resolved the problem

@JamesPoel
Copy link

use client: "dict-chrome-ex" resolved the problem

This does not work. Is there a solution?

@srghma
Copy link

srghma commented May 23, 2021

client: "dict-chrome-ex" works, but input should not be long

// const {Translate} = require('@google-cloud/translate').v2;
// const translate = new Translate({projectId: "annular-form-299211"});

const cache_path = 'google_translate_cache.json'

let google_translate_cache = {}
try { google_translate_cache = JSON.parse(fs.readFileSync(cache_path).toString()) } catch (e) { }

async function google_translate_with_cache(input, { from, to }) {
  const cache_key = [from, to].filter(x => x).join('|')

  if (!google_translate_cache[cache_key]) { google_translate_cache[cache_key] = {} }

  const google_translate_cache_to = google_translate_cache[cache_key]
  const x = google_translate_cache_to[input]
  if (x) { return x }

  // const translation = await translate(input, { from, to })
  // let translation_ = translation.data[0]
  const response = await require('google-translate-open-api').default(input, { from, to, client: "dict-chrome-ex" })

  let translation_ = response.data.sentences.map(x => x.trans).join('')

  google_translate_cache_to[input] = translation_

  return translation_
}

function google_translate_sync() {
  fs.writeFileSync(cache_path, JSON.stringify(google_translate_cache))
}

@sheptang
Copy link

You get 403 because of Google's CORS policy.
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at "https://translate.google.com/_/TranslateWebserverUi/data/batchexecute?...". (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 403.

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

No branches or pull requests