Skip to content

Commit ff31d8d

Browse files
committed
Handle invalid token format exceptions as invalid tokens
1 parent b9c36b5 commit ff31d8d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

oauth2_provider/views/mixins.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,13 @@ def dispatch(self, request, *args, **kwargs):
288288
if not valid:
289289
# Alternatively allow access tokens
290290
# check if the request is valid and the protected resource may be accessed
291-
valid, r = self.verify_request(request)
292-
if valid:
293-
request.resource_owner = r.user
294-
return super().dispatch(request, *args, **kwargs)
295-
else:
296-
return HttpResponseForbidden()
291+
try:
292+
valid, r = self.verify_request(request)
293+
if valid:
294+
request.resource_owner = r.user
295+
return super().dispatch(request, *args, **kwargs)
296+
except ValueError:
297+
pass
298+
return HttpResponseForbidden()
297299
else:
298300
return super().dispatch(request, *args, **kwargs)

0 commit comments

Comments
 (0)