A microservice that makes authentication with Spotify to your application simple.
This app (and this README) is a slightly modified version of micro-github
This microserver authenticates to spotify using the Authorization Code Flow, which is outlined in RFC-6749.
Using now
:
# Deploy this to now.sh
now ntaylor89/micro-spotify -e SPOTIFY_CLIENT_ID=12345 -e SPOTIFY_CLIENT_SECRET=ABCDE -e REDIRECT_URI=https://my-app.com
You'll need to provide three environment variables when running micro-spotify
:
# Your Spotify application client id
SPOTIFY_CLIENT_ID=12345
# Your Spotify application client secret
SPOTIFY_CLIENT_SECRET=ABCDE
# The URL to redirect the user to once the authentication was successful
REDIRECT_URI=https://my-app.com
Create an application on Spotify here if you haven't done that yet.
When authentication is successful, the user is redirected to the REDIRECT_URI
with the access_token
provided by spotify as a query param. You can then use this token to interact with Spotify.
To log people in, provide a link to the url now
provided with the login path. i.e.
https://path-from-now/login
When a user follows this link, they'll be sent to spotify to login.
If the user approves the authorizaiton, they will be send back to the REDIRECT_URI
with the access token from Spotify.
In case an error happens (either by micro-spotify
or on Spotify) the user will be redirected to the REDIRECT_URI with the error query param set to a relevant error message.
MIT
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some new feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Note that this repo follows JavaScript Standard Style
99.99% of this code was copied from micro-github