Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

286
Views
Función de nube de Google, ¿cómo configurar la ruta del archivo clave y evitar errores?

Creé una función en la nube que usa la API de Gmail para enviarme un correo electrónico. La función de nube es activada por un programador de nube de Google. Cuando pruebo esto localmente, parece funcionar, pero cuando subo mi función al editor de código de función de la nube de Google y la subo, hay un error en los registros. Tenga en cuenta que la función parece implementarse bien y está activa.

Este es el error de los registros:

ingrese la descripción de la imagen aquí

No estoy seguro de a qué keyFile se refiere o cómo configurarlo. Este es mi código:

 /** * Triggered from a message on a Cloud Pub/Sub topic. * * @param {!Object} event Event payload. * @param {!Object} context Metadata for the event. */ const {google} = require('googleapis'); const {authenticate} = require('@google-cloud/local-auth'); const gmail = google.gmail('v1'); const sendMail = async () => { // Obtain user credentials to use for the request const auth = await authenticate( process.env.client_id, process.env.client_secret, [ 'https://mail.google.com/', 'https://www.googleapis.com/auth/gmail.compose', 'https://www.googleapis.com/auth/gmail.send', ], ); google.options({auth}); // You can use UTF-8 encoding for the subject using the method below. // You can also just use a plain string if you don't need anything fancy. const subject = '🤘 Hello 🤘'; const utf8Subject = `=?utf-8?B?${Buffer.from(subject).toString('base64')}?=`; const messageParts = [ 'From: Oamar Kanji <oamarkanji@gmail.com', 'To: Oamar Kanji <oamarkanji@gmail.com>', 'Content-Type: text/html; charset=utf-8', 'MIME-Version: 1.0', `Subject: ${utf8Subject}`, '', 'This is a message just to say hello.', 'So... <b>Hello!</b> 🤘❤️😎', ]; const message = messageParts.join('\n'); // The body needs to be base64url encoded. const encodedMessage = Buffer.from(message) .toString('base64') .replace(/\+/g, '-') .replace(/\//g, '_') .replace(/=+$/, ''); const res = await gmail.users.messages.send({ userId: 'me', requestBody: { raw: encodedMessage, }, }); console.log(res.data); return res.data; } exports.alertPubSub = async (event, context) => { await sendMail() };
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!