Skip to content

Commit 6cbab3a

Browse files
committed
allow falsey but non-None grant uri params
1 parent 70a6bfa commit 6cbab3a

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

authlib/oauth2/rfc6749/parameters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def prepare_grant_uri(uri, client_id, response_type, redirect_uri=None,
6060
params.append(('state', state))
6161

6262
for k in kwargs:
63-
if kwargs[k]:
63+
if kwargs[k] is not None:
6464
params.append((to_unicode(k), kwargs[k]))
6565

6666
return add_params_to_uri(uri, params)

tests/core/test_oauth2/test_rfc6749_misc.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ def test_parse_implicit_response(self):
5050
rv,
5151
{'access_token': 'a', 'token_type': 'bearer', 'state': 'c'}
5252
)
53+
54+
def test_prepare_grant_uri(self):
55+
grant_uri = parameters.prepare_grant_uri('https://i.b/authorize', 'dev', 'code', max_age=0)
56+
self.assertEqual(
57+
grant_uri,
58+
"https://i.b/authorize?response_type=code&client_id=dev&max_age=0"
59+
)
5360

5461

5562
class OAuth2UtilTest(unittest.TestCase):

0 commit comments

Comments
 (0)