Spotify Auth
Cordova plugin for authenticating with Spotify
https://github.com/Festify/cordova-spotify-oauth
Stuck on a Cordova issue?
If you're building a serious project, you can't afford to spend hours troubleshooting. Ionicβs experts offer premium advisory services for both community plugins and premier plugins.
Installation
- Capacitor
- Cordova
- Enterprise
$ npm install cordova-spotify-oauth
$ npm install @awesome-cordova-plugins/spotify-auth
$ ionic cap sync
$ ionic cordova plugin add cordova-spotify-oauth
$ npm install @awesome-cordova-plugins/spotify-auth
Ionic Enterprise comes with fully supported and maintained plugins from the Ionic Team. Β Learn More or if you're interested in an enterprise version of this plugin Contact Us
Supported Platforms
- Android
- iOS
Usage
React
Learn more about using Ionic Native components in React
Angular
import { SpotifyAuth } from '@awesome-cordova-plugins/spotify-auth/ngx';
// [...]
constructor(private spotifyAuth: SpotifyAuth) { }
// [...]
const config = {
clientId: "<SPOTIFY CLIENT ID>",
redirectUrl: "<REDIRECT URL, MUST MATCH WITH AUTH ENDPOINT AND SPOTIFY DEV CONSOLE>",
scopes: ["streaming"], // see Spotify Dev console for all scopes
tokenExchangeUrl: "<URL OF TOKEN EXCHANGE HTTP ENDPOINT>",
tokenRefreshUrl: "<URL OF TOKEN REFRESH HTTP ENDPOINT>",
};
...
this.spotifyAuth.authorize(config)
.then(({ accessToken, expiresAt }) => {
console.log(`Got an access token, its ${accessToken}!`);
console.log(`Its going to expire in ${expiresAt - Date.now()}ms.`);
});
// [...]
this.spotifyAuth.forget();
// [...]