mirror of
https://github.com/c0de-archive/spotipy.git
synced 2025-01-06 14:52:50 +00:00
Merge pull request #206 from lastfm/feature/add-show-dialog-auth-option
Add show_dialog auth url option
This commit is contained in:
commit
d31214642d
@ -160,7 +160,7 @@ class SpotifyOAuth(object):
|
|||||||
def is_token_expired(self, token_info):
|
def is_token_expired(self, token_info):
|
||||||
return is_token_expired(token_info)
|
return is_token_expired(token_info)
|
||||||
|
|
||||||
def get_authorize_url(self, state=None):
|
def get_authorize_url(self, state=None, show_dialog=False):
|
||||||
""" Gets the URL to use to authorize this app
|
""" Gets the URL to use to authorize this app
|
||||||
"""
|
"""
|
||||||
payload = {'client_id': self.client_id,
|
payload = {'client_id': self.client_id,
|
||||||
@ -172,6 +172,8 @@ class SpotifyOAuth(object):
|
|||||||
state = self.state
|
state = self.state
|
||||||
if state is not None:
|
if state is not None:
|
||||||
payload['state'] = state
|
payload['state'] = state
|
||||||
|
if show_dialog:
|
||||||
|
payload['show_dialog'] = True
|
||||||
|
|
||||||
urlparams = urllibparse.urlencode(payload)
|
urlparams = urllibparse.urlencode(payload)
|
||||||
|
|
||||||
|
@ -146,6 +146,24 @@ class TestSpotifyOAuth(unittest.TestCase):
|
|||||||
parsed_qs = urllibparse.parse_qs(parsed_url.query)
|
parsed_qs = urllibparse.parse_qs(parsed_url.query)
|
||||||
self.assertEqual(parsed_qs['state'][0], state)
|
self.assertEqual(parsed_qs['state'][0], state)
|
||||||
|
|
||||||
|
def test_get_authorize_url_does_not_show_dialog_by_default(self):
|
||||||
|
oauth = SpotifyOAuth("CLID", "CLISEC", "REDIR")
|
||||||
|
|
||||||
|
url = oauth.get_authorize_url()
|
||||||
|
|
||||||
|
parsed_url = urllibparse.urlparse(url)
|
||||||
|
parsed_qs = urllibparse.parse_qs(parsed_url.query)
|
||||||
|
self.assertNotIn('show_dialog', parsed_qs)
|
||||||
|
|
||||||
|
def test_get_authorize_url_shows_dialog_when_requested(self):
|
||||||
|
oauth = SpotifyOAuth("CLID", "CLISEC", "REDIR")
|
||||||
|
|
||||||
|
url = oauth.get_authorize_url(show_dialog=True)
|
||||||
|
|
||||||
|
parsed_url = urllibparse.urlparse(url)
|
||||||
|
parsed_qs = urllibparse.parse_qs(parsed_url.query)
|
||||||
|
self.assertTrue(parsed_qs['show_dialog'])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user