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

359
Views
API de Gmail: conexión rechazada

Cuando llamo a getCode(), getToken(code) y getEmailData(token) de la siguiente clase en sucesión, aparece el error POST http://localhost:9000/api/email net::ERR_CONNECTION_REFUSED en

 const { data: { messagesTotal }, errors, } = await this.gmailClient.users.getProfile({ userId: "me", });

No puedo entender por qué esto es así, y es el caso entre los usuarios, con un acelerador y con la función de etiquetas de lista también. ¿Alguien sabe cuál podría ser el problema?

 export default class GmailClient { authClient; gmailClient; SCOPES = ["https://www.googleapis.com/auth/gmail.readonly"]; constructor() { //grab the credentials from the json file const credentials = JSON.parse( fs.readFileSync("controllers/credentials.json").toString() ); const { client_secret, client_id, redirect_uris } = credentials.web; this.authClient = new google.auth.OAuth2( client_id, client_secret, "http://localhost:3000" ); this.gmailClient = google.gmail({ version: "v1", auth: this.authClient }); } async getEmailData(token) { // no creds saved if (!this.authClient.credentials?.refresh_token) { this.authClient.setCredentials(token); this.gmailClient = google.gmail({ version: "v1", auth: this.authClient }); } const { data: { messagesTotal }, errors, } = await this.gmailClient.users.getProfile({ userId: "me", }); console.log("Error", errors); return { labels: [`Messages total ${messagesTotal}`] }; } getCode() { const authUrl = this.authClient.generateAuthUrl({ access_type: "offline", scope: this.SCOPES, }); return { authUrl }; } async getToken(code) { try { const { tokens } = await this.authClient.getToken(code); this.authClient.setCredentials(tokens); return { token: tokens }; } catch (err) { console.log("Error: Bad User Code: ", err); return res.json({ token: null }); } } }
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Mi parche para esto estaba usando

 axiosRetry(axios, { retries: 3, retryDelay: (retryCount) => { console.log(`Request retry attempt: ${retryCount}`); return retryCount * 2000; }, retryCondition: (error) => { console.log("Retrying on error: ", error); return error || error.response.status === 503; }, });
about 4 years ago · Santiago Trujillo Report
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!