Node.js API call giving a “bad base64 decode” error

Skip to first unread message

sc...@ucode.com

unread,
Sep 13, 2018, 8:49:11 PM9/13/18
to cloud-nl-discuss
I'm using Google's AutoML Natural Language API for Node.js. Everything works great, except for a particular service account and user (a student of mine). She gets the following error:
> Auth error:Error: error:0906D064:PEM routines:PEM_read_bio:bad base64 decode
> { Error: 14 UNAVAILABLE: Getting metadata from plugin failed with error: error:0906D064:PEM routines:PEM_read_bio:bad base64 decode
>     at Object.exports.createStatusError (/home/ubuntu/workspace/functions/node_modules/grpc/src/common.js:87:15)
>     at Object.onReceiveStatus (/home/ubuntu/workspace/functions/node_modules/grpc/src/client_interceptors.js:1188:28)
>     at InterceptingListener._callNext (/home/ubuntu/workspace/functions/node_modules/grpc/src/client_interceptors.js:564:42)
>     at InterceptingListener.onReceiveStatus (/home/ubuntu/workspace/functions/node_modules/grpc/src/client_interceptors.js:614:8)
>     at callback (/home/ubuntu/workspace/functions/node_modules/grpc/src/client_interceptors.js:841:24)
>   code: 14,
>   metadata: Metadata { _internal_repr: {} },
>   details: 'Getting metadata from plugin failed with error: error:0906D064:PEM routines:PEM_read_bio:bad base64 decode' }

The code that produces this error is:

    const automl = require('@google-cloud/automl')
    const client = new automl.v1beta1.PredictionServiceClient({keyFilename: 'key_file.json'})
    const formattedName = client.modelPath('<project-id>', 'us-central1', '<model-id>')
    const payload = {
    textSnippet: {
    content: 'Recognize this text',
    mimeType: 'text/plain'
    }
    }
    const request = {
      name: formattedName,
      payload,
    }
    client.predict(request)
      .then(responses => console.log(responses[0].payload[0]))
      .catch(console.error(err))

If I change *project-id*, *model-id*, and *key-file.json* to my own, then this works perfect. I've verified she's entering the correct project-id, model-id, and key-file.json (at least those are from the exact same places I found mine). Any ideas what's causing this?

Mona Attariyan

unread,
Sep 14, 2018, 1:10:18 AM9/14/18
to sc...@ucode.com, Ethan Bao, cloud-nl-discuss
+Ethan

--
© 2018 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Cloud Natural Language Discussion Google Group (cloud-nl-discuss@googlegroups.com) to participate in discussions with other members of the Cloud Natural Language community and the Cloud Natural Language Team.
---
You received this message because you are subscribed to the Google Groups "cloud-nl-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-nl-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to cloud-nl-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-nl-discuss/4a9f7bc1-9e49-4b9d-bb0a-263a98ad339c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ethan Bao

unread,
Sep 14, 2018, 1:33:03 AM9/14/18
to Mona Attariyan, sc...@ucode.com, cloud-nl...@googlegroups.com
Hi Scott,
Given this is an auth error, can you let this student double check that she is following the instruction (in step 5) to download the key file?

+Ethan

Email preferences: You received this email because you signed up for the Cloud Natural Language Discussion Google Group (cloud-nl...@googlegroups.com) to participate in discussions with other members of the Cloud Natural Language community and the Cloud Natural Language Team.

---
You received this message because you are subscribed to the Google Groups "cloud-nl-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-nl-discu...@googlegroups.com.
To post to this group, send email to cloud-nl...@googlegroups.com.

sc...@ucode.com

unread,
Sep 14, 2018, 1:36:03 AM9/14/18
to cloud-nl-discuss
Hi Ethan, she downloaded the key file during the creation of her service account, just like I did (and therefore showed her). I'll have her download a new key file though in next week's class.
Message has been deleted

sdomi...@google.com

unread,
Sep 14, 2018, 10:12:17 AM9/14/18
to cloud-nl-discuss
You said: "If I change *project-id*, *model-id*, and *key-file.json* to my own, then this works perfect."

Which makes me believe that you have your own project and she has her own. You can run the code properly on your own PC but she cannot on her own PC. 

However, upon looking at the "Auth error:Error: error:0906D064:PEM routines:PEM_read_bio:bad base64 decode" error message, it makes be believe that there might be an indentation issue with the key-file.json

If that's not the case, I would suggest you check if you both are running the code on same Nodejs version. 

Scott Mueller

unread,
Sep 19, 2018, 7:35:42 PM9/19/18
to sdomi...@google.com, cloud-nl...@googlegroups.com
Same node.js version. Each service account has the same permissions (AutoML Editor and Editor). No indentation issues :(. Still can't get it to work.

Scott Mueller
888-888-8681 x700
Teaching Kids to Program


--
© 2018 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Cloud Natural Language Discussion Google Group (cloud-nl...@googlegroups.com) to participate in discussions with other members of the Cloud Natural Language community and the Cloud Natural Language Team.
---
You received this message because you are subscribed to a topic in the Google Groups "cloud-nl-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cloud-nl-discuss/jQmleger4S8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cloud-nl-discu...@googlegroups.com.

To post to this group, send email to cloud-nl...@googlegroups.com.

Scott Mueller

unread,
Sep 19, 2018, 10:26:52 PM9/19/18
to sdomi...@google.com, cloud-nl...@googlegroups.com
We got everything to work by simply creating a second service account. Exact same permissions, key file looked exactly the same (different key of course).


Scott Mueller
888-888-8681 x700
Teaching Kids to Program

Reply all
Reply to author
Forward
0 new messages