summaryrefslogtreecommitdiff
path: root/oauthlib/oauth2/rfc6749
diff options
context:
space:
mode:
authorOmer Katz <omer.drow@gmail.com>2018-12-17 15:19:51 +0200
committerOmer Katz <omer.drow@gmail.com>2018-12-17 15:19:51 +0200
commit79c667eedae4a4d447e8229e37eb844e3af05374 (patch)
tree7844446bddb53bc12d79900c81f88259d1376928 /oauthlib/oauth2/rfc6749
parentcfd6af0168c27e74eb8fd300d42b3145cdea8a78 (diff)
downloadoauthlib-79c667eedae4a4d447e8229e37eb844e3af05374.tar.gz
Extract raising on unsupported token.
Diffstat (limited to 'oauthlib/oauth2/rfc6749')
-rw-r--r--oauthlib/oauth2/rfc6749/endpoints/base.py9
-rw-r--r--oauthlib/oauth2/rfc6749/endpoints/introspect.py6
-rw-r--r--oauthlib/oauth2/rfc6749/endpoints/revocation.py6
3 files changed, 10 insertions, 11 deletions
diff --git a/oauthlib/oauth2/rfc6749/endpoints/base.py b/oauthlib/oauth2/rfc6749/endpoints/base.py
index 638311d..3fd45c3 100644
--- a/oauthlib/oauth2/rfc6749/endpoints/base.py
+++ b/oauthlib/oauth2/rfc6749/endpoints/base.py
@@ -13,7 +13,7 @@ import logging
from ..errors import (FatalClientError, OAuth2Error, ServerError,
TemporarilyUnavailableError, InvalidRequestError,
- InvalidClientError)
+ InvalidClientError, UnsupportedTokenTypeError)
log = logging.getLogger(__name__)
@@ -55,6 +55,13 @@ class BaseEndpoint(object):
log.debug('Client authentication failed, %r.', request)
raise InvalidClientError(request=request)
+ def _raise_on_unspported_token(self, request):
+ """Raise on unsupported tokens."""
+ if (request.token_type_hint and
+ request.token_type_hint in self.valid_token_types and
+ request.token_type_hint not in self.supported_token_types):
+ raise UnsupportedTokenTypeError(request=request)
+
def catch_errors_and_unavailability(f):
@functools.wraps(f)
diff --git a/oauthlib/oauth2/rfc6749/endpoints/introspect.py b/oauthlib/oauth2/rfc6749/endpoints/introspect.py
index 5f24ff3..25dae1f 100644
--- a/oauthlib/oauth2/rfc6749/endpoints/introspect.py
+++ b/oauthlib/oauth2/rfc6749/endpoints/introspect.py
@@ -118,8 +118,4 @@ class IntrospectEndpoint(BaseEndpoint):
"""
self._raise_on_missing_token(request)
self._raise_on_invalid_client(request)
-
- if (request.token_type_hint and
- request.token_type_hint in self.valid_token_types and
- request.token_type_hint not in self.supported_token_types):
- raise UnsupportedTokenTypeError(request=request)
+ self._raise_on_unspported_token(request)
diff --git a/oauthlib/oauth2/rfc6749/endpoints/revocation.py b/oauthlib/oauth2/rfc6749/endpoints/revocation.py
index 8ec9512..f9a5648 100644
--- a/oauthlib/oauth2/rfc6749/endpoints/revocation.py
+++ b/oauthlib/oauth2/rfc6749/endpoints/revocation.py
@@ -117,8 +117,4 @@ class RevocationEndpoint(BaseEndpoint):
"""
self._raise_on_missing_token(request)
self._raise_on_invalid_client(request)
-
- if (request.token_type_hint and
- request.token_type_hint in self.valid_token_types and
- request.token_type_hint not in self.supported_token_types):
- raise UnsupportedTokenTypeError(request=request)
+ self._raise_on_unspported_token(request)