forked from thelinmichael/spotify-web-api-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient-credentials.js
More file actions
26 lines (23 loc) · 813 Bytes
/
client-credentials.js
File metadata and controls
26 lines (23 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const { util } = require('prettier');
var SpotifyWebApi = require('../');
/**
* This example uses the Client Credentials authorization flow.
*/
/**
* Get the credentials from Spotify's Dashboard page.
* https://developer.spotify.com/dashboard/applications
*/
const spotifyApi = new SpotifyWebApi({
clientId: '<Client ID>',
clientSecret: '<Client Secret>'
});
// Retrieve an access token using your credentials
spotifyApi.clientCredentialsGrant().
then(function(result) {
console.log('It worked! Your access token is: ' + result.body.access_token);
}).catch(function(err) {
console.log('If this is printed, it probably means that you used invalid ' +
'clientId and clientSecret values. Please check!');
console.log('Hint: ');
console.log(err);
});