List all tokens for this content instance.

        :param request: a WSGI request object
        :param kwargs: keyword arguments (optional)
        :return: `rest_framework.response.Response`
2911
def list_tokens(self, request, **kwargs):
        

        # no date checking is done here to make it more obvious if there's an issue with the
        # number of records. Date filtering will be done on the frontend.
        infos = [ObfuscatedUrlInfoSerializer(info).data
                 for info in ObfuscatedUrlInfo.objects.filter(content=self.get_object())]
        return Response(infos, status=status.HTTP_200_OK, content_type="application/json")
502725
def get_accept_list(self, request):
        
        header = request.META.get('HTTP_ACCEPT', '*/*')
        return [token.strip() for token in header.split(',')]
1318468
def list(self, request, *args, **kwargs):
        """"""
        search_kwargs = {"published": False}

        query_params = get_query_params(self.request)

        for field_name in ("status"):
            if field_name in query_params:
                search_kwargs[field_name] = query_params.get(field_name)

        if "search" in query_params:
            search_kwargs["query"] = query_params.get("search")

        # active/closed are semantics of the Poll model
        # active is analagous to 'published' in Content
        # closed is in relation to the end_date of a Poll
        if "active" in query_params:
            del search_kwargs["published"]
            search_kwargs["active"] = True

        if "closed" in query_params:
            del search_kwargs["published"]
            search_kwargs["closed"] = True

        queryset = self.model.search_objects.search(**search_kwargs)

        page = self.paginate_queryset(queryset)
        if page is not None:
            serializer = self.get_serializer(page, many=True)
            return self.get_paginated_response(serializer.data)

        serializer = self.get_serializer(queryset, many=True)
        return Response(serializer.data)
10379
def get_request_token(self):
        
        
        if self._request_token is None:
            self._request_token = self._get_request_token()
        return self._request_token
868057
async def get_request_token(self, loop=None, **params):
        """"""
        params = dict(self.params, **params)
        data = await self.request('GET', self.request_token_url, params=params, loop=loop)

        self.oauth_token = data.get('oauth_token')
        self.oauth_token_secret = data.get('oauth_token_secret')
        return self.oauth_token, self.oauth_token_secret, data
906225
async def render_list(self, request=None) -> List[Text]:
        
        from bernard.middleware import MiddlewareManager

        if request:
            tz = await request.user.get_timezone()
            locale = await request.get_locale()
            flags = await request.get_trans_flags()
        else:
            tz = None
            locale = self.wd.list_locales()[0]
            flags = {}

        rp = MiddlewareManager.instance()\
            .get('resolve_trans_params', self._resolve_params)

        resolved_params = await rp(self.params, request)

        f = I18nFormatter(self.wd.choose_locale(locale), tz)
        return self.wd.get(
            self.key,
            self.count,
            f,
            locale,
            resolved_params,
            flags,
        )
325697
def get_request_token(self, request):
        
        if self.oauth == 'oauth1':
            oauth = OAuth1Session(self.consumer_key, client_secret=self.consumer_secret)
            request_token = oauth.fetch_request_token(self.REQ_TOKEN)
            # Save the request token information for later
            request.session['oauth_token'] = request_token['oauth_token']
            request.session['oauth_token_secret'] = request_token['oauth_token_secret']

            return request_token
        else:
            callback_url = self.callback_url(request)
            oauth = OAuth2Session(client_id=self.consumer_key, redirect_uri=callback_url, scope=self.scope)
            authorization_url, state = oauth.authorization_url(self.AUTH_URL)
            return authorization_url
1255974
async def get_tags(self):
        
        params = {'access_token': self.token}
        path = '/api/tags.{ext}'.format(ext=self.format)
        return await self.query(path, "get", **params)
248384
def get_tokens(self, filters={}):
        
        uri = 'tokens'

        if filters:
            filters = {'filters': json.dumps(filters)}
            uri += "?%s" % urllib.urlencode(filters, True)

        resp, body = self.get(uri)
        self.expected_success(200, resp.status)
        body = json.loads(body)
        return rest_client.ResponseBody(resp, body)
961372
def parse(cls, request: web.Request) -> AuthWidgetData:
        
        try:
            query = dict(request.query)
            query['id'] = int(query['id'])
            query['auth_date'] = int(query['auth_date'])
            widget = AuthWidgetData(**query)
        except (ValueError, KeyError):
            raise web.HTTPBadRequest(text='Invalid auth data')
        else:
            return widget
659214
def get_jwt(self, request):
        
        try:
            authorization = request.authorization
        except ValueError:
            return None
        if authorization is None:
            return None
        authtype, token = authorization
        if authtype.lower() != self.auth_header_prefix.lower():
            return None
        return token
1373643
def get_token(self, code, headers=None, **kwargs):
        
        self._check_configuration("site", "token_url", "redirect_uri",
                                  "client_id", "client_secret")
        url = "%s%s" % (self.site, quote(self.token_url))
        data = {
            'redirect_uri': self.redirect_uri,
            'client_id': self.client_id,
            'client_secret': self.client_secret,
            'code': code,
        }
        data.update(kwargs)

        return self._make_request(url, data=data, headers=headers)
1285849
def list(self, url):
        
        url = self.get_full_url(url)
        self.log.debug("list url : " + url)
        # Building request
        request = urllib2.Request(url)
        request.add_header('Content-Type', 'application/json; charset=UTF-8')
        request.add_header('Accept', 'application/json')
        # Do request
        ret = self.do_request(request)
        self.log.debug("""list url : %(url)s : request time : %(time)s""",
                       {"url": url,
                        "time": self.last_req_time})
        return ret
1072155
def all(self):
        
        response = requests.get(self._url, **self._default_request_kwargs)
        data = self._get_response_data(response)
        return self._concrete_instance_list(data)
525904
def get_redirect(request):
        
        params = request.GET.copy()
        params.pop(TOKEN_NAME)
        url = request.path
        if params:
            url += '?' + urlencode(params)
        return redirect(url)
565326
def list(self, **kwds):
        
        tags = self._client.get("/tags/list.json", **kwds)["result"]
        tags = self._result_to_list(tags)
        return [Tag(self._client, tag) for tag in tags]
499220
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")