Skip to content

Fix default in getAuthenticationUrl to pass if requested #271

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

Merged
merged 5 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 7 additions & 6 deletions dropbox/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand All @@ -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'
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/test_dropbox_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down