Пример #1
0
    def get(self):

        account_id = session['user_id']
        logger.debug('Account id: ' + account_id)

        apikey = get_account_api_key(account_id=account_id)

        content_data = {'apikey': apikey}

        headers = {'Content-Type': 'text/html'}
        return make_response(
            render_template('profile/index.html', content_data=content_data),
            200, headers)
Пример #2
0
    def get(self):
        try:
            endpoint = str(api.url_for(self))
        except Exception as exp:
            endpoint = str(__name__)

        logger.info("Authenticating user")

        auth = request.authorization
        if not auth or not self.check_basic_auth(auth.username, auth.password):
            return self.authenticate()
        else:
            logger.info("Authenticated")

        try:
            api_key = get_account_api_key(account_id=self.account_id)
        except ApiKeyNotFoundError as exp:
            error_title = "ApiKey not found for authenticated user"
            logger.error(error_title)
            logger.error(repr(exp))
            raise ApiError(code=404,
                           title=error_title,
                           detail=repr(exp),
                           source=endpoint)
        except Exception as exp:
            error_title = "Could not get ApiKey for authenticated user"
            logger.error(error_title)
            logger.error(repr(exp))
            raise ApiError(code=500,
                           title=error_title,
                           detail=repr(exp),
                           source=endpoint)
        else:
            logger.debug("account_id: " + str(self.account_id))
            logger.debug("api_key: " + str(api_key))

        create_event_log_entry(account_id=int(self.account_id),
                               actor="AccountOwner",
                               action="GET",
                               resource=endpoint,
                               timestamp=get_utc_time())

        response_data = {
            'Api-Key-User': api_key,
            'account_id': str(self.account_id)
        }

        return make_json_response(data=response_data, status_code=200)
Пример #3
0
    def get(self):
        # account_id = session['user_id']
        # logger.debug('Account id: ' + account_id)

        auth = request.authorization
        if not auth or not self.check_basic_auth(auth.username, auth.password):
            return self.authenticate()

        api_key = get_account_api_key(account_id=self.account_id)


        response_data = {
            'api_key': api_key
        }

        return make_json_response(data=response_data, status_code=200)