Search docs/

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?

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.

Contact Us Today!

Installation

ionic cordova plugin add cordova-spotify-oauthnpm install @ionic-native/spotify-auth
Ionic Native 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

import { SpotifyAuth } from '@ionic-native/spotify-auth';

// [...]

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().then(() => console.log("We're logged out!"));

// [...]