Spotify Auth

Contents

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 official maintenance, support, and integration help.

Installation

ionic cordova plugin add cordova-spotify-oauthnpm install @ionic-native/spotify-auth
Ionic EE comes with fully supported and maintained plugins from the Ionic Team. Learn More or Contact Us
ionic enterprise register --key=YOURPRODUCTKEYnpm install @ionic-enterprise/spotify-auth

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!"));

// [...]