Skip to content

Instantly share code, notes, and snippets.

@leemartin
Created January 5, 2019 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leemartin/84f95b1a83eb1dec0e1243159dc899ee to your computer and use it in GitHub Desktop.
Save leemartin/84f95b1a83eb1dec0e1243159dc899ee to your computer and use it in GitHub Desktop.
Generate Spotify client credentials
const axios = require('axios')
let CLIENT_ID="YOUR_CLIENT_ID"
let CLIENT_SECRET="YOUR_CLIENT_SECRET"
let auth = Buffer.from(`${CLIENT_ID}:${CLIENT_SECRET}`).toString('base64')
axios({
method: 'post',
url: 'https://accounts.spotify.com/api/token',
headers: {
'Authorization': `Basic ${auth}`,
'Content-Type': 'application/x-www-form-urlencoded'
},
params: {
'grant_type': 'client_credentials'
}
}).then(response => {
console.log(response.data.access_token)
}).catch(error => {
console.log(error)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment