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

190
Views
Respuesta 403 al acceder a la API de Discord a través del entorno de extensión de Chrome

Estoy tratando de acceder al punto final de obtención de usuario de Discord. Mi objetivo es hacerlo a través de una extensión. El código en la extensión es el siguiente"

usuario.ts:

 interface discordUser { id: string username: string discriminator: string avatar: string bot: boolean system: boolean mfa_enabled: boolean banner: string accent_color: string locale: string verified: boolean email: string flags: number premium_type: number public_flags: number } export async function getUserData( userID: string, botKey: string ): Promise<string> { const res = await fetch(`https://discord.com/api/v9/users/${userID}`, { headers: { Authorization: `Bot ${botKey}`, }, }) if (!res.ok) { throw new Error(`Something went wrong ${res.status}`) } const data: discordUser = await res.json() return data.username }

Sin embargo, cuando intento ejecutar el siguiente código en la extensión de Chrome que estoy creando, recibo una respuesta 403:

 Failed to load resource: the server responded with a status of 403 () popup.js:79 Error: Something went wrong 403 at popup.js:118 at Generator.next (<anonymous>) at fulfilled (popup.js:104)

He intentado esencialmente lo mismo, pero en un tiempo de ejecución de nodo, el código es el siguiente:

 const fetch = require('node-fetch') async function getUserData(userID, botKey) { const res = await fetch(`https://discord.com/api/v9/users/${userID}`, { headers: { Authorization: `Bot ${botKey}`, }, }) const data = await res.json() console.log(data) } getUserData(userID, botkey)

Sorprendentemente, si ejecuto esencialmente el mismo código en Node, me da una respuesta positiva, con las características necesarias (toda la información del usuario):

 { id: '657988964107550739', username: "pepegan't", avatar: 'd2277fa1dac4b69115a0edf30b0fd53f', discriminator: '0409', public_flags: 128, banner: 'a0a2f731f1ca90b948449c1d2156d28f', banner_color: '#ee88ab', accent_color: 15632555 }

No estoy seguro de cuál es el problema aquí...

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!