Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

450
Vistas
GET call, get query params from callback url

I am making a GET call with the following URL

https://auth.ebay.com/oauth2/authorize?client_id=CLIENT_ID&response_type=code&redirect_uri=REDIRECT_URI&scope=https://api.ebay.com/oauth/api_scope

This URL will redirect me to a "success.php" website from my server. With that redirection, it adds in params to the URL. For example: https://www.example.com/success.php?code=12345.

I need to get that code param from this redirection. How can I do that?

I tried to do a basic .get() call, but it doesnt seem to work..

https.get(url, (resp) => {
  let data = '';

  // A chunk of data has been received.
  resp.on('data', (chunk) => {
    data += chunk;
  });

  // The whole response has been received. Print out the result.
  resp.on('end', () => {
    console.log(JSON.parse(data).explanation);
  });

}).on("error", (err) => {
  console.log("Error: " + err.message);
});

I have tried other ways that I thought would work from research on here, like waiting for the redirect, etc. Nothing seems to work.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Based on the code you already have it seems you might want the following.

var https = require('https');
var url = 'https://auth.ebay.com/oauth2/authorize?client_id=CLIENT_ID&response_type=code&redirect_uri=REDIRECT_URI&scope=https://api.ebay.com/oauth/api_scope';
https.get(url, (resp) => {
  
  var location = new URL(resp.headers.location);
 
  var code = location.searchParams.get('code');
  
  console.log(code);
  
}).on("error", (err) => {
  console.log("Error: " + err.message);
});

My answer assumes you are writing the code that is making the request while @Jordi Riera assumes you are writing code to process the request. Might you tell us which it is?

about 4 years ago · Juan Pablo Isaza Denunciar

0

It is a query param ( seems to me you are working with an oAuth flow, reading about how these flows work would also help you work out an approach to this)

So I would capture it the following way

app.get('/callback', function (req, res) {

   var code = req.query.code || null;
   console.log(code);

}

where /callback is the URL you are redirected to and where you can capture the code to request the authorization token

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda