v3: translateText fails after getSupportedLanguages using ADC
See original GitHub issueEnvironment details
- OS: macOS
- Node.js version: 14.12.0
- npm version: 6.14.8
@google-cloud/translate
version: 6.0.3
Steps to reproduce
- Login with ADC:
gcloud auth application-default login
- Install
@google-cloud/translate
with npm or yarn - Run the below script:
node script.js
- Check the output (also attached mine below)
- Notice that the first call
works.translateText
succeeds, but when callingfails.getSupportedLanguages
and thenfails.translateText
it fails.
const { TranslationServiceClient } = require('@google-cloud/translate')
async function test() {
const translateOpts = {
contents: ['Hello'],
targetLanguageCode: 'fr',
}
try {
const works = new TranslationServiceClient()
const parent = `projects/${await works.getProjectId()}`
const [translation] = await works.translateText({
parent,
...translateOpts,
})
console.info('[works] Translation succeeded:', translation)
} catch (ex) {
console.error('[works] Translation failed:', ex.message || ex)
}
try {
const fails = new TranslationServiceClient()
const parent = `projects/${await fails.getProjectId()}`
const [langs] = await fails.getSupportedLanguages({ parent })
console.info('[fails] Fetched supported languages:', langs.languages.length)
const [translation] = await fails.translateText({
parent,
...translateOpts,
})
console.info('[fails] Translation succeeded:', translation)
} catch (ex) {
console.error('[fails] Translation failed:', ex.message || ex)
}
}
test()
Output for me:
$ node translate-repo.js
[works] Translation succeeded: {
translations: [
{
translatedText: 'Bonjour',
model: '',
glossaryConfig: null,
detectedLanguageCode: 'en'
}
],
glossaryTranslations: []
}
[fails] Fetched supported languages: 111
[fails] Translation failed: 7 PERMISSION_DENIED: Your application has authenticated using end user credentials from the Google Cloud SDK or Google Cloud Shell which are not supported by the translate.googleapis.com. We recommend configuring the billing/quota_project setting in gcloud or using a service account through the auth/impersonate_service_account setting. For more information about service accounts and how to use them in your application, see https://cloud.google.com/docs/authentication/.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Package google.cloud.translation.v3
This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call. Authorization Scopes. Requires ...
Read more >Understanding and minimising ADC conversion errors
1 INTRODUCTION. The purpose of this document is to explain the different ADC errors and the techniques that application developers can use to...
Read more >c# - Google.Cloud.Translate.V3, error GRPC Failed to pick ...
we are developing a service that uses translation through Google and currently facing the following issue: translation through Google.Cloud.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
🤷♂️ not sure then I’m afraid, can’t reproduce with 6.1.0 anyway so maybe it was fixed in a dependency down the line… Thanks for looking into it anyway!
I’ll try reproducing again tomorrow, but have you tried that node version?
To reproduce the issue. Otherwise calling translateText would cause things to work. In production, just the second (failing) case is being used.