Skip to content

Commit 7454fdb

Browse files
committed
Return proper error when access token with no scope is sent to /secured/private/ping endpoint
1 parent 359fd7d commit 7454fdb

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

00-Starter-Seed/server.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ def requires_scope(required_scope):
7070
"""
7171
token = get_token_auth_header()
7272
unverified_claims = jwt.get_unverified_claims(token)
73-
token_scopes = unverified_claims["scope"].split()
74-
for token_scope in token_scopes:
75-
if token_scope == required_scope:
76-
return True
73+
if unverified_claims.get("scope"):
74+
token_scopes = unverified_claims["scope"].split()
75+
for token_scope in token_scopes:
76+
if token_scope == required_scope:
77+
return True
7778
return False
7879

7980

0 commit comments

Comments
 (0)