Skip to content

Commit

Permalink
Handle invalid token format exceptions as invalid tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkwelltwd committed Aug 28, 2020
1 parent 6b0bc35 commit c93d677
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions oauth2_provider/views/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,13 @@ def dispatch(self, request, *args, **kwargs):
if not valid:
# Alternatively allow access tokens
# check if the request is valid and the protected resource may be accessed
valid, r = self.verify_request(request)
if valid:
request.resource_owner = r.user
return super().dispatch(request, *args, **kwargs)
else:
return HttpResponseForbidden()
try:
valid, r = self.verify_request(request)
if valid:
request.resource_owner = r.user
return super().dispatch(request, *args, **kwargs)
except ValueError:
pass
return HttpResponseForbidden()
else:
return super().dispatch(request, *args, **kwargs)

0 comments on commit c93d677

Please sign in to comment.