@@ -153,8 +153,36 @@ def get(self, request, *args, **kwargs):
153153 status = 200 )
154154
155155 def post (self , request , * args , ** kwargs ):
156- # handle JSON post, sanitization etc.
157- pass
156+ body = request .POST
157+ client_id = body ["client_id" ]
158+ application = get_application_model ().objects .get (client_id = client_id )
159+ credentials = {
160+ "client_id" : body .get ("client_id" ),
161+ "redirect_uri" : body .get ("redirect_uri" ),
162+ "response_type" : body .get ("response_type" , None ),
163+ "state" : body .get ("state" , None ),
164+ }
165+ if body .get ("code_challenge" , False ):
166+ credentials ["code_challenge" ] = body .get ("code_challenge" )
167+ if body .get ("code_challenge_method" , False ):
168+ credentials ["code_challenge_method" ] = body .get ("code_challenge_method" )
169+ if body .get ("nonce" , False ):
170+ credentials ["nonce" ] = body .get ("nonce" )
171+ if body .get ("claims" , False ):
172+ credentials ["claims" ] = body .get ("claims" )
173+
174+ scopes = body .get ("scope" )
175+ allow = body .get ("allow" )
176+ try :
177+ uri , headers , body , status = self .create_authorization_response (
178+ request = self .request , scopes = scopes , credentials = credentials , allow = allow
179+ )
180+ except OAuthToolkitError as error :
181+ return self .error_response (error , application )
182+
183+ self .success_url = uri
184+ log .debug ("Success url for the request: {0}" .format (self .success_url ))
185+ return self .redirect (self .success_url , application )
158186
159187 class ExtendedEncoder (DjangoJSONEncoder ):
160188 def default (self , o ):
0 commit comments