1717from .models import Grant , AccessToken , RefreshToken , get_application_model , AbstractApplication
1818from .settings import oauth2_settings
1919
20+
2021log = logging .getLogger ('oauth2_provider' )
2122
2223GRANT_TYPE_MAPPING = {
3132class OAuth2Validator (RequestValidator ):
3233 def _extract_basic_auth (self , request ):
3334 """
34- Return authentication string if request contains basic auth credentials, else return None
35+ Return authentication string if request contains basic auth credentials,
36+ otherwise return None
3537 """
3638 auth = request .headers .get ('HTTP_AUTHORIZATION' , None )
3739 if not auth :
@@ -93,11 +95,12 @@ def _authenticate_basic_auth(self, request):
9395
9496 def _authenticate_request_body (self , request ):
9597 """
96- Try to authenticate the client using client_id and client_secret parameters
97- included in body.
98+ Try to authenticate the client using client_id and client_secret
99+ parameters included in body.
98100
99- Remember that this method is NOT RECOMMENDED and SHOULD be limited to clients unable to
100- directly utilize the HTTP Basic authentication scheme. See rfc:`2.3.1` for more details.
101+ Remember that this method is NOT RECOMMENDED and SHOULD be limited to
102+ clients unable to directly utilize the HTTP Basic authentication scheme.
103+ See rfc:`2.3.1` for more details.
101104 """
102105 # TODO: check if oauthlib has already unquoted client_id and client_secret
103106 try :
@@ -117,8 +120,8 @@ def _authenticate_request_body(self, request):
117120
118121 def _load_application (self , client_id , request ):
119122 """
120- If request.client was not set, load application instance for given client_id and store it
121- in request.client
123+ If request.client was not set, load application instance for given
124+ client_id and store it in request.client
122125 """
123126
124127 # we want to be sure that request has the client attribute!
@@ -141,11 +144,11 @@ def client_authentication_required(self, request, *args, **kwargs):
141144 * Resource owner password grant
142145 * Refresh token grant
143146
144- If the request contains authorization headers, always authenticate the client no matter
145- the grant type.
147+ If the request contains authorization headers, always authenticate the client
148+ no matter the grant type.
146149
147- If the request does not contain authorization headers, proceed with authentication only if
148- the client is of type `Confidential`.
150+ If the request does not contain authorization headers, proceed with authentication
151+ only if the client is of type `Confidential`.
149152
150153 If something goes wrong, call oauthlib implementation of the method.
151154 """
@@ -172,9 +175,10 @@ def authenticate_client(self, request, *args, **kwargs):
172175
173176 First we try to authenticate with HTTP Basic Auth, and that is the PREFERRED
174177 authentication method.
175- Whether this fails we support including the client credentials in the request-body, but
176- this method is NOT RECOMMENDED and SHOULD be limited to clients unable to directly utilize
177- the HTTP Basic authentication scheme. See rfc:`2.3.1` for more details
178+ Whether this fails we support including the client credentials in the request-body,
179+ but this method is NOT RECOMMENDED and SHOULD be limited to clients unable to
180+ directly utilize the HTTP Basic authentication scheme.
181+ See rfc:`2.3.1` for more details
178182 """
179183 authenticated = self ._authenticate_basic_auth (request )
180184
0 commit comments