def token_endpoint(self, context):
        """
        Handle token requests (served at /token).
        :type context: satosa.context.Context
        :rtype: oic.utils.http_util.Response

        :param context: the current context
        :return: HTTP response to the client
        """
        headers = {"Authorization": context.request_authorization}
        try:
            response = self.provider.handle_token_request(urlencode(context.request), headers)
            return Response(response.to_json(), content="application/json")
        except InvalidClientAuthentication as e:
            logger.debug('invalid client authentication at token endpoint', exc_info=True)
            error_resp = TokenErrorResponse(error='invalid_client', error_description=str(e))
            response = Unauthorized(error_resp.to_json(), headers=[("WWW-Authenticate", "Basic")],
                                    content="application/json")
            return response
        except OAuthError as e:
            logger.debug('invalid request: %s', str(e), exc_info=True)
            error_resp = TokenErrorResponse(error=e.oauth_error, error_description=str(e))
            return BadRequest(error_resp.to_json(), content="application/json")
def token_endpoint ( self , context ) : headers = { "Authorization" : context . request_authorization } try : response = self . provider . handle_token_request ( urlencode ( context . request ) , headers ) return Response ( response . to_json ( ) , content = "application/json" ) except InvalidClientAuthentication as e : logger . debug ( 'invalid client authentication at token endpoint' , exc_info = True ) error_resp = TokenErrorResponse ( error = 'invalid_client' , error_description = str ( e ) ) response = Unauthorized ( error_resp . to_json ( ) , headers = [ ( "WWW-Authenticate" , "Basic" ) ] , content = "application/json" ) return response except OAuthError as e : logger . debug ( 'invalid request: %s' , str ( e ) , exc_info = True ) error_resp = TokenErrorResponse ( error = e . oauth_error , error_description = str ( e ) ) return BadRequest ( error_resp . to_json ( ) , content = "application/json" )
Handle token requests (served at /token).
        :type context: satosa.context.Context
        :rtype: oic.utils.http_util.Response

        :param context: the current context
        :return: HTTP response to the client