11import logging
22
3+ from django .contrib .auth .mixins import LoginRequiredMixin
34from django .http import HttpResponse
45from django .utils import timezone
56from django .utils .decorators import method_decorator
89from django .views .generic import FormView , View
910
1011from .mixins import OAuthLibMixin
11- from ..compat import LoginRequiredMixin
1212from ..exceptions import OAuthToolkitError
1313from ..forms import AllowForm
1414from ..http import HttpResponseUriRedirect
@@ -166,6 +166,7 @@ def get(self, request, *args, **kwargs):
166166 return self .error_response (error )
167167
168168
169+ @method_decorator (csrf_exempt , name = "dispatch" )
169170class TokenView (OAuthLibMixin , View ):
170171 """
171172 Implements an endpoint to provide access tokens
@@ -179,11 +180,6 @@ class TokenView(OAuthLibMixin, View):
179180 validator_class = oauth2_settings .OAUTH2_VALIDATOR_CLASS
180181 oauthlib_backend_class = oauth2_settings .OAUTH2_BACKEND_CLASS
181182
182- # XXX: Django 1.8 compat
183- @method_decorator (csrf_exempt )
184- def dispatch (self , * args , ** kwargs ):
185- return super (TokenView , self ).dispatch (* args , ** kwargs )
186-
187183 @method_decorator (sensitive_post_parameters ('password' ))
188184 def post (self , request , * args , ** kwargs ):
189185 url , headers , body , status = self .create_token_response (request )
@@ -194,6 +190,7 @@ def post(self, request, *args, **kwargs):
194190 return response
195191
196192
193+ @method_decorator (csrf_exempt , name = "dispatch" )
197194class RevokeTokenView (OAuthLibMixin , View ):
198195 """
199196 Implements an endpoint to revoke access or refresh tokens
@@ -202,10 +199,6 @@ class RevokeTokenView(OAuthLibMixin, View):
202199 validator_class = oauth2_settings .OAUTH2_VALIDATOR_CLASS
203200 oauthlib_backend_class = oauth2_settings .OAUTH2_BACKEND_CLASS
204201
205- # XXX: Django 1.8 compat
206- def dispatch (self , * args , ** kwargs ):
207- return super (RevokeTokenView , self ).dispatch (* args , ** kwargs )
208-
209202 def post (self , request , * args , ** kwargs ):
210203 url , headers , body , status = self .create_revocation_response (request )
211204 response = HttpResponse (content = body or '' , status = status )
0 commit comments