Created
January 5, 2019 15:01
-
-
Save leemartin/84f95b1a83eb1dec0e1243159dc899ee to your computer and use it in GitHub Desktop.
Generate Spotify client credentials
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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