Skip to content

Commit 43f7191

Browse files
authored
Fix default in getAuthenticationUrl to pass if requested (#271)
* Fix default in getAuthenticationUrl to pass if requested * Update to default to none
1 parent f4ca18f commit 43f7191

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

dropbox/oauth.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def __repr__(self):
118118

119119
class DropboxOAuth2FlowBase(object):
120120

121-
def __init__(self, consumer_key, consumer_secret=None, locale=None, token_access_type='legacy',
121+
def __init__(self, consumer_key, consumer_secret=None, locale=None, token_access_type=None,
122122
scope=None, include_granted_scopes=None, use_pkce=False, timeout=DEFAULT_TIMEOUT):
123123
if scope is not None and (len(scope) == 0 or not isinstance(scope, list)):
124124
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
146146
self.code_verifier = None
147147
self.code_challenge = None
148148

149-
def _get_authorize_url(self, redirect_uri, state, token_access_type, scope=None,
149+
def _get_authorize_url(self, redirect_uri, state, token_access_type=None, scope=None,
150150
include_granted_scopes=None, code_challenge=None):
151151
params = dict(response_type='code',
152152
client_id=self.consumer_key)
@@ -156,8 +156,7 @@ def _get_authorize_url(self, redirect_uri, state, token_access_type, scope=None,
156156
params['state'] = state
157157
if token_access_type is not None:
158158
assert token_access_type in TOKEN_ACCESS_TYPES
159-
if token_access_type != 'legacy':
160-
params['token_access_type'] = token_access_type
159+
params['token_access_type'] = token_access_type
161160
if code_challenge:
162161
params['code_challenge'] = code_challenge
163162
params['code_challenge_method'] = 'S256'
@@ -273,7 +272,7 @@ class DropboxOAuth2FlowNoRedirect(DropboxOAuth2FlowBase):
273272
274273
"""
275274

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

360360
def __init__(self, consumer_key, redirect_uri, session,
361361
csrf_token_session_key, consumer_secret=None, locale=None,
362-
token_access_type='legacy', scope=None,
362+
token_access_type=None, scope=None,
363363
include_granted_scopes=None, use_pkce=False, timeout=DEFAULT_TIMEOUT):
364364
"""
365365
Construct an instance.
@@ -380,6 +380,7 @@ def __init__(self, consumer_key, redirect_uri, session,
380380
:param str token_access_type: The type of token to be requested.
381381
From the following enum:
382382
383+
* None - creates a token with the app default (either legacy or online)
383384
* legacy - creates one long-lived token with no expiration
384385
* online - create one short-lived token with an expiration
385386
* offline - create one short-lived token with an expiration with a refresh token

test/test_dropbox_unit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_authorization_url(self):
5858
else:
5959
assert 'state' not in authorization_url
6060

61-
if token_access_type and token_access_type != 'legacy':
61+
if token_access_type:
6262
assert 'token_access_type={}'.format(token_access_type) \
6363
in authorization_url
6464
else:

0 commit comments

Comments
 (0)