Skip to content

Instantly share code, notes, and snippets.

@iamhunter
Created June 15, 2017 14:31
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 iamhunter/e6acf65c73c7e21a7b203c1275958e32 to your computer and use it in GitHub Desktop.
Save iamhunter/e6acf65c73c7e21a7b203c1275958e32 to your computer and use it in GitHub Desktop.
Spotify setup part 2
// The code that's returned as a query parameter to the redirect URI
var code = '';
// Retrieve an access token and a refresh token
spotifyApi.authorizationCodeGrant(code)
.then(function(data) {
console.log('The token expires in ' + data.body['expires_in']);
console.log('The access token is ' + data.body['access_token']);
console.log('The refresh token is ' + data.body['refresh_token']);
// Set the access token on the API object to use it in later calls
spotifyApi.setAccessToken(data.body['access_token']);
spotifyApi.setRefreshToken(data.body['refresh_token']);
}, function(err) {
console.log('Something went wrong!', err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment