googleapis / google-cloud-node

Google Cloud Client Library for Node.js
https://cloud.google.com/nodejs
Apache License 2.0
2.87k stars 582 forks source link

Error : "permission denied on resources" Trying to implement @google-cloud/speech Verison 5.4.1(i.e V2) in Node JS #4221

Open DixitMalia opened 1 year ago

DixitMalia commented 1 year ago

I am writing to request assistance with an issue I have encountered while implementing the Google Speech-to-Text gRPC API in my project. Specifically, I am receiving an error message indicating "permission denied on resources" when attempting to use the API.

I have followed the API documentation and have ensured that my credentials are valid and have the appropriate permissions. However, despite my best efforts, I have been unable to resolve this issue and am currently unable to proceed with my project.

I would greatly appreciate any assistance or guidance you can provide in resolving this issue. Please let me know if there is any additional information I can provide to help diagnose the problem.

Thank you in advance for your help.

OS Verison : Ubuntu 20 Node Verison : 19.8.1 Google Cloud Speech API Veriosn : gRPC 5.4.1 (i.e Verison 2)

ERROR SHOWN BELOW

0|ASR | Error: 7 PERMISSION_DENIED: Permission 'speech.recognizers.list' denied on resource '//speech.googleapis.com/projects/gifted-airway-380611/locations/global' (or it may not exist). 0|ASR | at callErrorFromStatus (/home/ubuntu/telephony/call_ai_asr_main/call_ai_asr/node_modules/@grpc/grpc-js/build/src/call.js:31:19) 0|ASR | at Object.onReceiveStatus (/home/ubuntu/telephony/call_ai_asr_main/call_ai_asr/node_modules/@grpc/grpc-js/build/src/client.js:192:76) 0|ASR | at Object.onReceiveStatus (/home/ubuntu/telephony/call_ai_asr_main/call_ai_asr/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:360:141) 0|ASR | at Object.onReceiveStatus (/home/ubuntu/telephony/call_ai_asr_main/call_ai_asr/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:323:181) 0|ASR | at /home/ubuntu/telephony/call_ai_asr_main/call_ai_asr/node_modules/@grpc/grpc-js/build/src/resolving-call.js:94:78 0|ASR | at process.processTicksAndRejections (node:internal/process/task_queues:77:11) 0|ASR | for call at 0|ASR | at ServiceClientImpl.makeUnaryRequest (/home/ubuntu/telephony/call_ai_asr_main/call_ai_asr/node_modules/@grpc/grpc-js/build/src/client.js:160:34) 0|ASR | at ServiceClientImpl. (/home/ubuntu/telephony/call_ai_asr_main/call_ai_asr/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19) 0|ASR | at /home/ubuntu/telephony/call_ai_asr_main/call_ai_asr/node_modules/@google-cloud/speech/build/src/v2/speech_client.js:318:29 0|ASR | at wrappedCall (/home/ubuntu/telephony/call_ai_asr_main/call_ai_asr/node_modules/google-gax/build/src/paginationCalls/pagedApiCaller.js:86:20) 0|ASR | at /home/ubuntu/telephony/call_ai_asr_main/call_ai_asr/node_modules/google-gax/build/src/normalCalls/timeout.js:44:16 0|ASR | at repeat (/home/ubuntu/telephony/call_ai_asr_main/call_ai_asr/node_modules/google-gax/build/src/normalCalls/retries.js:80:25) 0|ASR | at Immediate. (/home/ubuntu/telephony/call_ai_asr_main/call_ai_asr/node_modules/google-gax/build/src/normalCalls/retries.js:118:13) 0|ASR | at process.processImmediate (node:internal/timers:480:21) { 0|ASR | code: 7, 0|ASR | details: "Permission 'speech.recognizers.list' denied on resource '//speech.googleapis.com/projects/gifted-airway-380611/locations/global' (or it may not exist).", 0|ASR | metadata: Metadata { 0|ASR | internalRepr: Map(2) { 0|ASR | 'google.rpc.errorinfo-bin' => [Array], 0|ASR | 'grpc-status-details-bin' => [Array] 0|ASR | }, 0|ASR | options: {} 0|ASR | }, 0|ASR | note: 'Exception occurred in retry method that was not classified as transient', 0|ASR | statusDetails: [ 0|ASR | ErrorInfo { 0|ASR | metadata: [Object], 0|ASR | reason: 'IAM_PERMISSION_DENIED', 0|ASR | domain: 'speech.googleapis.com' 0|ASR | } 0|ASR | ], 0|ASR | reason: 'IAM_PERMISSION_DENIED', 0|ASR | domain: 'speech.googleapis.com', 0|ASR | errorInfoMetadata: { 0|ASR | resource: 'projects/gifted-airway-380611/locations/global', 0|ASR | permission: 'speech.recognizers.list' 0|ASR | } 0|ASR | }

sofisl commented 1 year ago

Hi @DixitMalia, would you mind providing your code to reproduce as well? Thank you!

DixitMalia commented 1 year ago

Hi @sofisl this is the complete code from where i made the request and hit the gRPC API and get the response `const { Writable } = require('stream'); const {SpeechClient} = require('@google-cloud/speech').v2; /*

/*

const DEFAULT_ENCODING = "MULAW"; const DEFAULT_SAMPLE_RATE = 8000; const DEFAULT_LANGUAGE = "en-US"; //en-US const DEFAULT_RESTART_TIME = 60; // in seconds const DEFAULT_MAX_RESULTS = 100; const DEFAULT_MODEL = "phone_call";

/**

/**

module.exports = { getProvider, } `

lvxduck commented 1 year ago

@DixitMalia

Following this doc: https://cloud.google.com/speech-to-text/v2/docs/transcribe-client-libraries

You must add Cloud Speech Administrator role to get list recognizers.

image

DixitMalia commented 1 year ago

@lvxduck Thank you for your reply Speech to Text key used here is already having an admin role and IAM Permission