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

228
Views
Autenticación de credenciales de cliente de Spotify usando Fetch

¿Cómo puedo obtener el token api de spotify usando fetch ?

El sitio web de spotify tiene un ejemplo como este:

 var client_id = 'CLIENT_ID'; var client_secret = 'CLIENT_SECRET'; var authOptions = { url: 'https://accounts.spotify.com/api/token', headers: { 'Authorization': 'Basic ' + (new Buffer(client_id + ':' + client_secret).toString('base64')) }, form: { grant_type: 'client_credentials' }, json: true }; request.post(authOptions, function(error, response, body) { if (!error && response.statusCode === 200) { var token = body.access_token; } });

¿Se puede traducir eso a fetch ? Si es así, ¿cómo?

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

0

No lo probé con credenciales reales, pero debería funcionar:

 var client_id = 'CLIENT_ID'; var client_secret = 'CLIENT_SECRET'; fetch('https://accounts.spotify.com/api/token', { method: 'POST', body: 'grant_type=client_credentials&client_id=' + client_id + '&client_secret=' + client_secret, headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }) .then(r => r.json()) .then(r => { console.log(r.access_token) })

También podría usar el new FormData() para crear datos de formulario en lugar de urlencoded.

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!