0

I'm trying to authenticate on Google but I get an error:

length octect is too long at: (shallow)

This is my code:

I use this version in my package.json:

"google-auth-library": "^8.9.0",
import { JWT } from 'google-auth-library';

const key = "-----BEGIN PUBLIC KEY-----" + "key" + "-----END PUBLIC KEY-----"

const serviceAccountAuth = new JWT({
    email,
    key, 
    scopes: [
        'https://www.googleapis.com/auth/spreadsheets',
        'https://www.googleapis.com/auth/drive',
      ],
  });

When I try to sign I get this error:

asyncToGenerator.js:6 Uncaught (in promise) ReporterError {path: '', message: 'length octect is too long at: (shallow)', stack: 'Error: length octect is too long at: (shallow)\n   …calhost:3000/static/js/vendors~main.chunk.js:98:7'}
switch (type) {
  case 'CERTIFICATE':
    ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo
    // falls through
  case 'PUBLIC KEY':
    if (!ndata) {
      ndata = asn1.PublicKey.decode(data, 'der') <= Error line

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  try {
    var info = gen[key](arg);
    var value = info.value;
  } catch (error) {
    reject(error);
    return;
  }

I don't know what I'm doing wrong. I just want to create an authentication for Google Spreadsheets.

Thanks in advance for the help.

I would like to have a successful authentication to interact with Google APIs.

dodrg
  • 1,142
  • 2
  • 18
Sco
  • 1

0 Answers0