-
Notifications
You must be signed in to change notification settings - Fork 0
/
spotifyapps.html
62 lines (57 loc) · 1.96 KB
/
spotifyapps.html
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html>
<head>
<title>Spotify Player with Tone.js</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tone/14.8.29/Tone.min.js"></script>
<script src="https://sdk.scdn.co/spotify-player.js"></script>
<script>
/**
* This is an example of a basic node.js script that performs
* the Client Credentials oAuth2 flow to authenticate against
* the Spotify Accounts.
*
* For more information, read
* https://developer.spotify.com/web-api/authorization-guide/#client_credentials_flow
*/
//let accessToken = 'f1692e4b1b6d44d4bafa58860c5cf9ca';
//let searchTerm = 'puff the magic dragon';
// Spotify API credentials
//const client_id = 'f1692e4b1b6d44d4bafa58860c5cf9ca';
//const redirect_uri = 'https://eliasds.github.io/Binaural-Learning/README.md';
//const redirect_uri = 'https://eliasds.github.io/Binaural-Learning/spotify.html';
var request = require('request'); // "Request" library
var client_id = 'f1692e4b1b6d44d4bafa58860c5cf9ca'; // Your client id
var client_secret = '8ff25be359644a799aa4a36a311bd7cb'; // Your secret
// your application requests authorization
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) {
// use the access token to access the Spotify Web API
var token = body.access_token;
var options = {
url: 'https://api.spotify.com/v1/users/jmperezperez',
headers: {
'Authorization': 'Bearer ' + token
},
json: true
};
request.get(options, function(error, response, body) {
console.log(body);
});
}
});
</script>
<body>
<h1>Spotify Player with Tone.js V34</h1>
<h2>Tone.js puts one song in the left channel and another in the right</h2>
</body>
</html>