-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspotifyAuthConfig.js
35 lines (31 loc) · 1.09 KB
/
spotifyAuthConfig.js
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
module.exports.spotifyAuthConfig = () => {
const baseAuthUrl = 'https://accounts.spotify.com/authorize';
const tokenUrl = 'https://accounts.spotify.com/api/token';
const scopes = [
'app-remote-control',
'streaming',
'playlist-modify-public',
'playlist-modify-private',
'playlist-read-private',
'playlist-read-collaborative',
'user-read-currently-playing',
'user-read-recently-played',
'user-library-read',
'user-modify-playback-state',
];
const clientId = process.env.CLIENT_ID;
const clientSecret = process.env.CLIENT_SECRET;
const redirectUri = `https://sleepy-plateau-12982.herokuapp.com/`;
const authorizationHeaderString =
'Basic ' +
Buffer.from(clientId + ':' + clientSecret).toString('base64');
const authUrl = `${baseAuthUrl}?response_type=code&client_id=${clientId}&scope=${scopes.join(
'%20'
)}&redirect_uri=${encodeURIComponent(redirectUri)}`;
return {
authUrl,
tokenUrl,
redirectUri,
authorizationHeaderString,
};
};