Parse request as Telegram auth widget data.

        :param request:
        :return: :obj:`AuthWidgetData`
        :raise: :obj:`aiohttp.web.HTTPBadRequest`
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
202599
def _send_api_request(self, request, captcha_response=None):
        
        url = self.API_URL + request.method_name

        # Prepare request arguments
        method_kwargs = {'v': self.api_version}

        # Shape up the request data
        for values in (request.method_args,):
            method_kwargs.update(stringify_values(values))

        if self.is_token_required() or self._service_token:
            # Auth api call if access_token hadn't been gotten earlier
            method_kwargs['access_token'] = self.access_token

        if captcha_response:
            method_kwargs['captcha_sid'] = captcha_response['sid']
            method_kwargs['captcha_key'] = captcha_response['key']

        http_params = dict(url=url,
                           data=method_kwargs,
                           **request.http_params)
        logger.debug('send_api_request:http_params: %s', http_params)
        response = self.http_session.post(**http_params)
        return response
1232719
def _get_token(request):
    
    token = request.headers.get('Authorization')
    if not token:
        message = 'Token not in Authorization header'
        logging.warning(message)
        raise HTTPError(401, message)
    return token
344360
def get_auth_data
      auth_key  = @@http_auth_headers.detect { |h| request.env.has_key?(h) }
      auth_data = request.env[auth_key].to_s.split unless auth_key.blank?
      return auth_data && auth_data[0] == 'Basic' ? Base64.decode64(auth_data[1]).split(':')[0..1] : [nil, nil]
    end
120900
def post(self, request, *args, **kwargs):
        
        input_data = json.loads(request.body.decode('utf-8'))

        if 'text' not in input_data:
            return JsonResponse({
                'text': [
                    'The attribute "text" is required.'
                ]
            }, status=400)

        response = self.chatterbot.get_response(input_data)

        response_data = response.serialize()

        return JsonResponse(response_data, status=200)
252415
public function prepareRequest(TelegramRequest $request)
    {
        $url = $this->getBaseBotUrl().$request->getAccessToken().'/'.$request->getEndpoint();

        return [
            $url,
            $request->getMethod(),
            $request->getHeaders(),
            $request->isAsyncRequest(),
        ];
    }
945715
def process_request(self, request):
        
        token = request.GET.get(TOKEN_NAME)
        user = None if token is None else authenticate(url_auth_token=token)

        # If the sessions framework is enabled and the token is valid,
        # persist the login in session.
        if hasattr(request, 'session') and user is not None:
            login(request, user)
            # Once we persist the login in the session, if the authentication
            # middleware is enabled, it will set request.user in future
            # requests. We can get rid of the token in the URL by redirecting
            # to the same URL with the token removed. We only do this for GET
            # requests because redirecting POST requests doesn't work well. We
            # don't do this on Safari because it triggers the over-zealous
            # "Protection Against First Party Bounce Trackers" of ITP 2.0.
            if (
                hasattr(request, 'user') and
                request.method == 'GET' and
                not self.is_safari(request)
            ):
                return self.get_redirect(request)

        # If the authentication middleware isn't enabled, set request.user.
        # (This attribute is overwritten by the authentication middleware
        # if it runs after this one.)
        if not hasattr(request, 'user'):
            request.user = user if user is not None else AnonymousUser()
504329
def get_widget(self, request):
        
        return self._update_widget_choices(self.field.formfield(widget=RestrictedSelectWidget).widget)
628410
def _post_parse_request(self, request, client_id='', **kwargs):
        

        request = RefreshAccessTokenRequest(**request.to_dict())

        try:
            keyjar = self.endpoint_context.keyjar
        except AttributeError:
            keyjar = ""

        request.verify(keyjar=keyjar, opponent_id=client_id)

        if "client_id" not in request:  # Optional for refresh access token request
            request["client_id"] = client_id

        logger.debug("%s: %s" % (request.__class__.__name__, sanitize(request)))

        return request
185794
def get_widget(self, request):
        
        widget = self.widget
        if isinstance(widget, type):
            widget = widget()
        return widget
943014
protected static void fetchAnonymousAccessTokenAndRunRequest(final Request request) {
        fetchAnonymousAccessToken(request.getUserId(), new ResponseHandler() {
            @Override
            public void onSuccess(Response response) {
                requestAuthenticated(request);
            }

            @Override
            public void onFailure(Throwable e, Response errorResponse) {
            }
        });
    }
1374291
def _do_request(request):
    
    if request.request_type is RequestType.GET:
        return requests.get(request.url, headers=request.headers)
    if request.request_type is RequestType.POST:
        return requests.post(request.url, data=json.dumps(request.post_values), headers=request.headers)
    raise ValueError('Invalid request type {}'.format(request.request_type))
22394
def get(self, request, bot_id, id, format=None):
                
        return super(TelegramBotDetail, self).get(request, bot_id, id, format)
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
474215
def parse_auth_token(self, auth_token):
        
        # remove the random security key value from the front of the auth_token
        auth_token_cleaned = auth_token.split('-', 1)[1]
        # URL Decode the Auth Token
        auth_token_decoded = self.url_decode(auth_token_cleaned)
        # Create a new dict to hold the response.
        auth_dict = {}

        # Parse the token
        for key_value in auth_token_decoded.split("&"):
            key_value_list = key_value.split("=")
            # check for valid token parts
            if len(key_value_list) == 2 and type(key_value_list[0]) in [text_type, binary_type]:
                auth_dict[key_value_list[0]] = key_value_list[1]

        # Return the dict of key/values in the token.
        return auth_dict
219571
def extract_client_auth(request):
    
    auth_header = request.META.get('HTTP_AUTHORIZATION', '')

    if re.compile('^Basic\s{1}.+$').match(auth_header):
        b64_user_pass = auth_header.split()[1]
        try:
            user_pass = b64decode(b64_user_pass).decode('utf-8').split(':')
            client_id, client_secret = tuple(user_pass)
        except Exception:
            client_id = client_secret = ''
    else:
        client_id = request.POST.get('client_id', '')
        client_secret = request.POST.get('client_secret', '')

    return (client_id, client_secret)
682194
def get(self, request, *args, **kwargs):
        
        serializer = self.serializer_reader_class
        if request.user.is_authenticated():
            return Response(serializer(request.user, context=self.get_serializer_context()).data)
        else:
            return Response({'detail': _('Authentication credentials were not provided')}, status=401)