@@ -32,6 +32,7 @@ class BaseAuthorizationView(LoginRequiredMixin, OAuthLibMixin, View):
32
32
* Implicit grant
33
33
34
34
"""
35
+
35
36
def dispatch (self , request , * args , ** kwargs ):
36
37
self .oauth2_data = {}
37
38
return super ().dispatch (request , * args , ** kwargs )
@@ -132,6 +133,16 @@ def form_valid(self, form):
132
133
def get (self , request , * args , ** kwargs ):
133
134
try :
134
135
scopes , credentials = self .validate_authorization_request (request )
136
+ # TODO: Remove the two following lines after oauthlib updates its implementation
137
+ # https://github.com/jazzband/django-oauth-toolkit/pull/707#issuecomment-485011945
138
+ credentials ["code_challenge" ] = credentials .get (
139
+ "code_challenge" ,
140
+ request .GET .get ("code_challenge" , None )
141
+ )
142
+ credentials ["code_challenge_method" ] = credentials .get (
143
+ "code_challenge_method" ,
144
+ request .GET .get ("code_challenge_method" , None )
145
+ )
135
146
except OAuthToolkitError as error :
136
147
# Application is not available at this time.
137
148
return self .error_response (error , application = None )
@@ -149,8 +160,8 @@ def get(self, request, *args, **kwargs):
149
160
kwargs ["redirect_uri" ] = credentials ["redirect_uri" ]
150
161
kwargs ["response_type" ] = credentials ["response_type" ]
151
162
kwargs ["state" ] = credentials ["state" ]
152
- kwargs ["code_challenge" ] = credentials . get ( "code_challenge" , None )
153
- kwargs ["code_challenge_method" ] = credentials . get ( "code_challenge_method" , None )
163
+ kwargs ["code_challenge" ] = credentials [ "code_challenge" ]
164
+ kwargs ["code_challenge_method" ] = credentials [ "code_challenge_method" ]
154
165
155
166
self .oauth2_data = kwargs
156
167
# following two loc are here only because of https://code.djangoproject.com/ticket/17795
0 commit comments