def post(self):
     response = None
     try:
         client_id = self._get_client_id_from_request()
         client_secret = self._get_client_secret_from_request()
         response = self._create_access_token_response(
             Token.create(client_id, client_secret))
     except Exception as e:
         status_code = 403
         msg = "Cannot create tokens, invalid credentials"
         response = create_error_response(status_code, msg)
     return response
Exemplo n.º 2
0
    async def get(self, user):

        if user.is_remote:
            resp.status = falcon.HTTP_401
            resp.body = json.dumps({"Error": "Remote user"})

        token = Token.create(user=user)

        payload = {"token": "Bearer " + token.key}

        self.write(payload)
        self.set_status(200)
Exemplo n.º 3
0
    def on_get(self, req, resp):
        user = req.context['user']

        if user.remote:
            resp.status = falcon.HTTP_401
            resp.body = json.dumps({"Error": "Remote user"})

        token = Token.create(user=user)

        payload = {"token": token.key}

        resp.status = falcon.HTTP_200
        resp.body = json.dumps({"token": auth_backend.get_auth_token(payload)})