Spotify Personal Auth
A Spotify authorization code flow implementation for local personal use.
Install
Install with npm:
$ npm i spotify-personal-auth --save
Usage
const auth = require('spotify-personal-auth')
const SpotifyWebApi = require('spotify-web-api-node')
auth.config({
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
scope: ['user-modify-playback-state', 'user-top-read'],
path: '/path/to/a/tokens.json'
})
const api = new SpotifyWebApi()
auth.token().then(([token, refresh]) => {
api.setAccessToken(token)
api.setRefreshToken(refresh)
return api.getMyTopTracks()
}).then(data =>
api.play({
uris: data['body']['items'].map(item => item['uri'])
})
).catch(console.log)
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running Tests
Install dev dependencies:
$ npm i -d && npm test
Author
Tomer Aberbach
License
Copyright © 2019 Tomer Aberbach
Released under the MIT license.