stackjohnny
stackjohnny

Reputation: 805

Not able to set google speech constructor using credential options

Hello I am trying not to use json approach and to use credential option to initiate the gcloud speech client.

         const speech = require('@google-cloud/speech');

         const client = new speech.SpeechClient({credentials:{private_key : "", client_email: ""}}});

but this is giving me Error: 3 INVALID_ARGUMENT: Request contains an invalid argument error.

I have used dialog flow and other services in the same fashion and that is working fine, please advise if I am missing something here.

Upvotes: 0

Views: 271

Answers (1)

marian.vladoi
marian.vladoi

Reputation: 8074

Can you try:

   const speech = require('@google-cloud/speech');
   const config = { projectId: 'your-project', keyFilename:'key.json'};
   const client = new speech.SpeechClient(config);

In your code you have an extra }, this worked for me.

   const client = new speech.SpeechClient({credentials:{private_key : private_key, client_email: client_email}});

Upvotes: 1

Related Questions