Skip to main content

Spotify Auth

Cordova plugin for authenticating with Spotify

https://github.com/Festify/cordova-spotify-oauth

https://github.com/Festify/cordova-spotify-oauth

Stuck on a Cordova issue?

Don't waste precious time on plugin issues.

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#

$ npm install cordova-spotify-oauth
$ npm install @ionic-native/spotify-auth
$ ionic cap sync

Supported Platforms#

  • Android
  • iOS

Usage#

React#

Learn more about using Ionic Native components in React

Angular#

import { SpotifyAuth } from '@ionic-native/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();
// [...]