Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 'show_dialog' parameter when creating authorization url #101

Merged
merged 2 commits into from
Aug 24, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/spotify-web-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1258,15 +1258,16 @@ SpotifyWebApi.prototype = {
* @param {string} state A parameter that you can use to maintain a value between the request and the callback to redirect_uri.It is useful to prevent CSRF exploits.
* @returns {string} The URL where the user can give application permissions.
*/
createAuthorizeURL: function(scopes, state) {
createAuthorizeURL: function(scopes, state, showDialog) {
var request = AuthenticationRequest.builder()
.withPath('/authorize')
.withQueryParameters({
'client_id' : this.getClientId(),
'response_type' : 'code',
'redirect_uri' : this.getRedirectURI(),
'scope' : scopes.join('%20'),
'state' : state
'state' : state,
'show_dialog' : showDialog
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to not pass it or initialise it to false. Otherwise devs that don't pass it will see show_dialog=undefined in the URL.

})
.build();

Expand Down
7 changes: 4 additions & 3 deletions test/spotify-web-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1325,15 +1325,16 @@ describe('Spotify Web API', function() {
var scopes = ['user-read-private', 'user-read-email'],
redirectUri = 'https://example.com/callback',
clientId = '5fe01282e44241328a84e7c5cc169165',
state = 'some-state-of-my-choice';
state = 'some-state-of-my-choice',
showDialog = true;

var api = new SpotifyWebApi({
clientId : clientId,
redirectUri : redirectUri
});

var authorizeURL = api.createAuthorizeURL(scopes, state);
'https://accounts.spotify.com/authorize?client_id=5fe01282e44241328a84e7c5cc169165&response_type=code&redirect_uri=https://example.com/callback&scope=user-read-private%20user-read-email&state=some-state-of-my-choice'.should.equal(authorizeURL);
var authorizeURL = api.createAuthorizeURL(scopes, state, showDialog);
'https://accounts.spotify.com/authorize?client_id=5fe01282e44241328a84e7c5cc169165&response_type=code&redirect_uri=https://example.com/callback&scope=user-read-private%20user-read-email&state=some-state-of-my-choice&show_dialog=true'.should.equal(authorizeURL);
});

it('should set, get and reset credentials successfully', function() {
Expand Down