Get the URL on Spotify that a user should visit to authorize the specified Spotify app (i.e. your app).

This is the URL where you typically redirect a user in order for them to grant access to your Spotify app.


Hover over inputs/exits for more info.

var Spotify = require('machinepack-spotify');

// Get the URL on Spotify that a user should visit to authorize the specified Spotify app (i.e. your app).


clientId: 'abc123jdhs3h4js',

redirectUri: '',

responseType: [ 'code' ],

state: '34fFs29kd09',

scope: '*',

dialog: 'false',


// An unexpected error occurred.

error: function (err) {



// OK.

success: function (result) {





clientId required

The clientId for your Spotify app. The client ID provided to you by Spotify when you register your application.

redirectUri required

The URI to redirect to after the user grants/denies permission. This URI needs to have been entered in the Redirect URI whitelist that you specified when you registered your application.


(code, token_and_code)

[ 'code' ]

The state can be useful for correlating requests and responses. Because your redirect_uri can be guessed, using a state value can increase your assurance that an incoming connection is the result of an authentication request. If you generate a random string or encode the hash of some client state (e.g., a cookie) in this state variable, you can validate the response to additionally ensure that the request and response originated in the same browser.


A space-separated list of scopes: see Using Scopes. If no scopes are specified, authorization will be granted only to access publicly available information: that is, only information normally visible in the Spotify desktop, web and mobile players.


Whether or not to force the user to approve the app again if they’ve already done so. If false (default), a user who has already approved the application may be automatically redirected to the URI specified by redirect_uri. If true, the user will not be automatically redirected and will have to approve the app again.




An unexpected error occurred.