Skip to content

elbywan/spotify-zeroconf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spotify-zeroconf

Spotify Web API authentication, the easy way.

npm version


About this library

spotify-zeroconf is a partial rewrite of librespot that has one goal:

To provide you with a Spotify Web API token without having to input your username and password.

How does it work

Basically, this library takes advantage of the Spotify Connect protocol and brodcasts itself as a Spotify compatible device on your network. Once you click on the device using any Spotify client (desktop, mobile…), it will perform multiple handshakes and authentication rounds with the Spotify access points, and provide you with a token that you will be able to use with the Spotify Web API.


Click to get the credentials!


There are more details in the librespot wiki (especially the Authentication and Connection parts).

Installation

npm i spotify-zeroconf

Usage

const spotifyZeroconf = require('spotify-zeroconf')

// Only clientId is required.
const credentials = await spotifyZeroconf({
    clientId: // [Required] Id of your spotify application
    scope: // Scopes with a comma separator. Defaults to a list containing every scope. (see here: https://developer.spotify.com/documentation/general/guides/scopes/)
    deviceName: // Name of the device that appears on the network. Defaults to 'Spotify Zeroconf'.
    noCache: // If true, will not store the first handshake credentials and will force the device to appear on the network every time the function is called. Defaults to false.
    authType: // 'token' (default) or 'code'. Code will give you an access code that you can exchange for a token and a refresh_token, but you will need the client_secret. (see here: https://developer.spotify.com/documentation/general/guides/authorization-guide/#2-have-your-application-request-refresh-and-access-tokens-spotify-returns-access-and-refresh-tokens)
})

// Web API token.
console.log(credentials.accessToken)

About

Spotify Web API authentication, the easy way.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published