Skip to content

Commit

Permalink
Fix default in getAuthenticationUrl to pass if requested (#271)
Browse files Browse the repository at this point in the history
* Fix default in getAuthenticationUrl to pass  if requested
* Update to default to none
rogebrd authored Oct 21, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent f4ca18f commit 43f7191
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions dropbox/oauth.py
Original file line number Diff line number Diff line change
@@ -118,7 +118,7 @@ def __repr__(self):

class DropboxOAuth2FlowBase(object):

def __init__(self, consumer_key, consumer_secret=None, locale=None, token_access_type='legacy',
def __init__(self, consumer_key, consumer_secret=None, locale=None, token_access_type=None,
scope=None, include_granted_scopes=None, use_pkce=False, timeout=DEFAULT_TIMEOUT):
if scope is not None and (len(scope) == 0 or not isinstance(scope, list)):
raise BadInputException("Scope list must be of type list")
@@ -146,7 +146,7 @@ def __init__(self, consumer_key, consumer_secret=None, locale=None, token_access
self.code_verifier = None
self.code_challenge = None

def _get_authorize_url(self, redirect_uri, state, token_access_type, scope=None,
def _get_authorize_url(self, redirect_uri, state, token_access_type=None, scope=None,
include_granted_scopes=None, code_challenge=None):
params = dict(response_type='code',
client_id=self.consumer_key)
@@ -156,8 +156,7 @@ def _get_authorize_url(self, redirect_uri, state, token_access_type, scope=None,
params['state'] = state
if token_access_type is not None:
assert token_access_type in TOKEN_ACCESS_TYPES
if token_access_type != 'legacy':
params['token_access_type'] = token_access_type
params['token_access_type'] = token_access_type
if code_challenge:
params['code_challenge'] = code_challenge
params['code_challenge_method'] = 'S256'
@@ -273,7 +272,7 @@ class DropboxOAuth2FlowNoRedirect(DropboxOAuth2FlowBase):
"""

def __init__(self, consumer_key, consumer_secret=None, locale=None, token_access_type='legacy',
def __init__(self, consumer_key, consumer_secret=None, locale=None, token_access_type=None,
scope=None, include_granted_scopes=None, use_pkce=False, timeout=DEFAULT_TIMEOUT): # noqa: E501;
"""
Construct an instance.
@@ -286,6 +285,7 @@ def __init__(self, consumer_key, consumer_secret=None, locale=None, token_access
:param str token_access_type: the type of token to be requested.
From the following enum:
* None - creates a token with the app default (either legacy or online)
* legacy - creates one long-lived token with no expiration
* online - create one short-lived token with an expiration
* offline - create one short-lived token with an expiration with a refresh token
@@ -359,7 +359,7 @@ class DropboxOAuth2Flow(DropboxOAuth2FlowBase):

def __init__(self, consumer_key, redirect_uri, session,
csrf_token_session_key, consumer_secret=None, locale=None,
token_access_type='legacy', scope=None,
token_access_type=None, scope=None,
include_granted_scopes=None, use_pkce=False, timeout=DEFAULT_TIMEOUT):
"""
Construct an instance.
@@ -380,6 +380,7 @@ def __init__(self, consumer_key, redirect_uri, session,
:param str token_access_type: The type of token to be requested.
From the following enum:
* None - creates a token with the app default (either legacy or online)
* legacy - creates one long-lived token with no expiration
* online - create one short-lived token with an expiration
* offline - create one short-lived token with an expiration with a refresh token
2 changes: 1 addition & 1 deletion test/test_dropbox_unit.py
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ def test_authorization_url(self):
else:
assert 'state' not in authorization_url

if token_access_type and token_access_type != 'legacy':
if token_access_type:
assert 'token_access_type={}'.format(token_access_type) \
in authorization_url
else:

0 comments on commit 43f7191

Please sign in to comment.