Options
All
  • Public
  • Public/Protected
  • All
Menu

Spotify Authorization Module

Used for managing Spotify Session

import { auth as SpotifyAuth, remote as SpotifyRemote, ApiScope, ApiConfig } from 'react-native-spotify-remote';
const spotifyConfig: ApiConfig = {
    clientID: "SPOTIFY_CLIENT_ID",
    redirectURL: "SPOTIFY_REDIRECT_URL",
    tokenRefreshURL: "SPOTIFY_TOKEN_REFRESH_URL",
    tokenSwapURL: "SPOTIFY_TOKEN_SWAP_URL",
    scope: ApiScope.AppRemoteControlScope | ApiScope.UserFollowReadScope
}
async function playEpicSong(){
    try{
        const token = await SpotifyAuth.initialize(spotifyConfig);
        await SpotifyRemote.connect(token);
        SpotifyRemote.playUri("spotify:track:6IA8E2Q5ttcpbuahIejO74#0:38");
    }catch(err){
        console.error("Couldn't authorize with or connect to Spotify",err);
    }
}

Hierarchy

  • SpotifyAuth

Index

Methods

authorize

endSession

  • endSession(): Promise<void>
  • Ends the current Session and cleans up any resources

    memberof

    SpotifyAuth

    Returns Promise<void>

getSession

  • Returns the current session or undefined if a session hasn't been started

    memberof

    SpotifyAuth

    Returns Promise<undefined | SpotifySession>

initialize

  • initialize(config: ApiConfig): Promise<string>
  • Initializes a Session with Spotify and returns an accessToken that can be used for interacting with other services

    deprecated

    Use authorize instead, will be removed in future release

    Parameters

    Returns Promise<string>

    accessToken

Legend

  • Property
  • Method

Generated using TypeDoc