-
Notifications
You must be signed in to change notification settings - Fork 12
API
- spotify.Session
- Properties
- spotify.AudioPlayer
- Methods
- Events
- spotify.Playlist
- Methods
- Properties
- spotify.Album
- Properties
- spotify.Artist
- Properties
- spotify.Track
- Properties
Authenticate the user with the Spotify API
spotify.authenticate(clientId, tokenExchangeURL, [scopes], callback)the clientId supplied by Spotify.
The URL for your token exchange service. See setting up a token exchange service
Custom scopes to request from the Spotify authentication service
The callback gets two arguments error and session. session is a spotifySession object.
Normally a spotify.Session object is returned from spotify.authenticate() but you can use the spotify.Session object to store the session for later use. A session is valid for 24 hours after which the user will need to login again.
var session = spotify.Session({username: 'someUsername', credentials: 'AFD42....GD43'});The username of the user.
An access token to verify the session.
The constructor for a new spotify.AudioPlayer object.
spotify.AudioPlayer(companyName, appName, session, callback)Your company name
Your application name
The user's spotify.Session object.
The callback gets two arguments error and an spotify.AudioPlayer object, ready to start playing tracks.
These examples show how to construct a spotify.AudioPlayer and play a track.
spotify.AudioPlayer('Your-Company-Name', 'Your-App-Name', session, function(error, audioPlayer) {
audioPlayer.playURI('spotify:track:6JEK0CvvjDjjMUBFoXShNZ');
});