コード例 #1
0
    def exec_main_proc(self):
        request_params = {
                'start': self.params['start'],
                'end': self.params['end'],
                'subject': self.event['requestContext']['authorizer']['claims']['cognito:username']
        }
        try:
            response = requests.get(
                settings.AUTHLETE_CLIENT_ENDPOINT + '/authorization/get/list',
                params=request_params,
                auth=(os.environ['AUTHLETE_API_KEY'], os.environ['AUTHLETE_API_SECRET'])
            )

        except requests.exceptions.RequestException as err:
            raise Exception('Something went wrong when call Authlete API: {0}'.format(err))

        AuthleteUtil.verify_valid_response(response)

        result = []
        for client in json.loads(response.text).get('clients', []):
            result.append({
                'clientId': client['clientId'],
                'clientName': client['clientName'],
                'clientType': client['clientType'],
                'createdAt': client['createdAt'],
                'description': client.get('description')
            })

        return {
            'statusCode': 200,
            'body': json.dumps(result)
        }
コード例 #2
0
    def exec_main_proc(self):
        create_params = {
            'clientName':
            self.params['name'],
            'description':
            self.params.get('description'),
            'applicationType':
            self.params['application_type'],
            'clientType':
            self.__get_client_type_from_application_type(
                self.params['application_type']),
            'developer':
            self.event['requestContext']['authorizer']['claims']
            ['cognito:username'],
            'redirectUris':
            self.params['redirect_urls'],
            'grantTypes': ['AUTHORIZATION_CODE', 'REFRESH_TOKEN'],
            'responseTypes': ['CODE']
        }
        try:
            response = requests.post(
                settings.AUTHLETE_CLIENT_ENDPOINT + '/create',
                json.dumps(create_params),
                headers={'Content-Type': 'application/json'},
                auth=(os.environ['AUTHLETE_API_KEY'],
                      os.environ['AUTHLETE_API_SECRET']))
        except requests.exceptions.RequestException as err:
            raise Exception(
                'Something went wrong when call Authlete API: {0}'.format(err))

        AuthleteUtil.verify_valid_response(response)

        return {'statusCode': 200, 'body': response.text}
コード例 #3
0
    def exec_main_proc(self):
        try:
            response = requests.get(settings.AUTHLETE_CLIENT_ENDPOINT +
                                    '/get/' + str(self.params['client_id']),
                                    auth=(os.environ['AUTHLETE_API_KEY'],
                                          os.environ['AUTHLETE_API_SECRET']))
        except requests.exceptions.RequestException as err:
            raise Exception(
                'Something went wrong when call Authlete API: {0}'.format(err))

        AuthleteUtil.verify_valid_response(
            response, request_client_id=self.params['client_id'])

        return {'statusCode': 200, 'body': response.text}
コード例 #4
0
    def exec_main_proc(self):
        subject = self.event['requestContext']['authorizer']['claims'][
            'cognito:username']
        url = settings.AUTHLETE_CLIENT_ENDPOINT + '/authorization/delete/' + str(
            self.params['client_id']) + '/' + subject
        try:
            response = requests.delete(
                url,
                auth=(os.environ['AUTHLETE_API_KEY'],
                      os.environ['AUTHLETE_API_SECRET']))
        except requests.exceptions.RequestException as err:
            raise Exception(
                'Something went wrong when call Authlete API: {0}'.format(err))

        AuthleteUtil.verify_valid_response(
            response, request_client_id=self.params['client_id'])

        return {'statusCode': 200, 'body': '{"result": "OK"}'}
コード例 #5
0
    def exec_main_proc(self):
        index_params = {
            'developer':
            self.event['requestContext']['authorizer']['claims']
            ['cognito:username']
        }

        try:
            response = requests.get(settings.AUTHLETE_CLIENT_ENDPOINT +
                                    '/get/list',
                                    params=index_params,
                                    auth=(os.environ['AUTHLETE_API_KEY'],
                                          os.environ['AUTHLETE_API_SECRET']))

        except requests.exceptions.RequestException as err:
            raise Exception(
                'Something went wrong when call Authlete API: {0}'.format(err))

        AuthleteUtil.verify_valid_response(response)

        return {'statusCode': 200, 'body': response.text}