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

363
Views
Redirect_uri no válido en solicitud Discord Oauth2

Miré otros problemas como el mío, por ejemplo este o este . Pero los problemas se deben a que los URI utilizados no están en los URI de redirección en la configuración de Discord OAuth2, y los verifiqué varias veces.

Tengo el siguiente código:

 import querySring from 'query-string' // I'm using React Router for this const code = searchParams.get('code') if (!code) return const data = { 'client_id': 'my client id', 'client_secret': 'my client secret', 'grant_type': 'authorization_code', 'code': code, 'redirect_uri': querySring.stringifyUrl({ url: 'http://localhost:3000/login/callback' }), } const strData = querySring.stringify(data) const headers = { 'Content-Type': 'application/x-www-form-urlencoded' } fetch('https://discord.com/api/oauth2/token', { method: 'POST', headers, body: strData, }) .then(res => res.json()) .then(console.log)

Y me sale el siguiente error:

 error: "invalid_request", error_description: "Invalid \"redirect_uri\" in request."

Por supuesto, me aseguré de tener este uri de redireccionamiento en el Portal para desarrolladores de Discord: Configuración de URL de redirección

También probé usando:

 const data = { // ... 'redirect_uri': 'http://localhost:3000/login/callback' }

Pero nada, no puedo encontrar lo que está mal.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Como me dijo space en Discord API Server , si estoy manejando el inicio de sesión desde la interfaz, debería usar response_type=token en lugar de response_type=code

Entonces puedo:

 const token = searchParams.get('access_token') const tokenType = searchParams.get('token_type') /// For some reason the returned url is giving # instead of ? for query if (window.location.toString().split('#').length > 1) { window.location.replace(window.location.toString().replace('#', '?')) } if (!token || !tokenType) return console.log(`There is no token`) const headers = { authorization: `${tokenType} ${token}` }

Y use estos encabezados para obtener datos:

 fetch('https://discord.com/api/users/@me', { headers, }) .then(res => res.json()) .then(user=> { // ... })
about 4 years ago · Juan Pablo Isaza 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!