Example #1
0
    def acquire_token(self, request, scopes=None):
        """A method to acquire current valid token with the given scope.

        :param request: Django HTTP request instance
        :param scopes: a list of scope values
        :return: token object
        """
        url = request.get_raw_uri()
        req = HttpRequest(request.method, url, request.body, request.headers)
        req.req = request
        if isinstance(scopes, str):
            scopes = [scopes]
        token = self.validate_request(scopes, req)
        token_authenticated.send(sender=self.__class__, token=token)
        return token
Example #2
0
    def acquire_token(self, scopes=None):
        """A method to acquire current valid token with the given scope.

        :param scopes: a list of scope values
        :return: token object
        """
        request = HttpRequest(_req.method, _req.full_path, _req.data,
                              _req.headers)
        request.req = _req
        # backward compatible
        if isinstance(scopes, str):
            scopes = [scopes]
        token = self.validate_request(scopes, request)
        token_authenticated.send(self, token=token)
        ctx = _app_ctx_stack.top
        ctx.authlib_server_oauth2_token = token
        return token