An Apache Cordova plugin providing a thin wrapper over the Spotify SDK for iOS and Android.
This plugin provides a very thin layer over the authentication and playback functionality of the Spotify SDK. It allows your users to authenticate using OAuth 2.0 and allows you to play Spotify tracks via their URI. Metadata functionality has deliberately been left out in favor of the Web API. After your users have been authenticated, you are given the access token, so accessing the Web API is trivial.
This plugin is currently in beta. This means its reasonably stable but hasn't seen much production use yet. This plugin will be used in the new Festify, so it will be production-ready once Festify is released. We will fix bugs as soon as we find them.
Pull requests are very welcome! Please use the gitmoji style for commit messages.
git clone https://github.com/Festify/cordova-spotify
cd ./MyCordovaProject
cordova plugin add ../cordova-spotify
An npm-based installation as well as API documentation will be provided at a later stage when the stability has improved.
Note: Make sure your installation path doesn't contain any spaces.
The Spotify SDK needs some server code because you don't want to login your users repeatedly every hour: Documentation
To implement the endpoints for tokenSwapURL
and tokenRefreshURL
we built a Serverless service that you can deploy to AWS Lambda. Make sure you install the Serverless Framework properly!
For the execution of the functions to work you need to set some environmental configuration in the file oauth-token-api/.env
CLIENT_ID="<Your Spotify Client ID>"
CLIENT_SECRET="<Your Spotify Client Secret>"
CLIENT_CALLBACK_URL="<The callback url of your app>" # e.g. "festify-spotify://callback"
ENCRYPTION_SECRET="<Secret used to encrypt the refresh token - please generate>"
You can then deploy the functions to AWS:
cd oauth-token-api
serverless deploy
Also, you need to register the client callback protocol inside the App Info.plist so that iOS knows which app to start when it is redirected when the authentication is done. Take a look at this repository to see how it's done.