This method gets the token and makes the header variable that 
            will be used in connection authentication. After that, calls 
            the _make_request() method to return the desired data.
547569
def _get_content(self, params, mode_translate):
        
        token = self._get_token()
        headers = {'Authorization': 'Bearer '+ token}
        parameters = params
        translation_url = mode_translate
        return self._make_request(parameters, translation_url, headers)
271402
def get_request_token(
        cls, consumer_key, redirect_uri='http://example.com/', state=None
    ):
        '''
        

        '''
        headers = {
            'X-Accept': 'application/json',
        }
        url = 'https://getpocket.com/v3/oauth/request'
        payload = {
            'consumer_key': consumer_key,
            'redirect_uri': redirect_uri,
        }

        if state:
            payload['state'] = state

        return cls._make_request(url, payload, headers)[0]['code']
864234
def _request(self, url, method = u"get", data = None, headers=None, **kwargs):
        
        #        if self.access_token:
        #            auth_header = {
        #                u"Authorization": "Bearer %s" % (self.access_token)
        #            }
        #            headers.update(auth_header)
        #basic auth
        msg = "method: %s url:%s\nheaders:%s\ndata:%s" % (
            method, url, headers, data)
        #print msg
        if not self.use_oauth:
            auth = (self.sk_user, self.sk_pw)
            if not self.client:
                self.client = requests.session()
            r = self.client.request(method, url, headers=headers, data=data, auth=auth,**kwargs)
        else:
            if not self.client:
                self.client = requests.session(hooks={'pre_request': oauth_hook})
            r = self.client.request(method, url, headers=headers, data=data,**kwargs)
        return r
883908
def get_token(self):
    
    if self.__token is not None:
      return self.__token

    url = "https://api.neur.io/v1/oauth2/token"

    creds = b64encode(":".join([self.__key,self.__secret]).encode()).decode()

    headers = {
      "Authorization": " ".join(["Basic", creds]),
    }
    payload = {
      "grant_type": "client_credentials"
    }

    r = requests.post(url, data=payload, headers=headers)

    self.__token = r.json()["access_token"]

    return self.__token
529195
def _get_oauth_token(self):
        
        url = urljoin(self.api_url, '/oauth2/token')

        oauth = OAuth2Session(
            client_id=self._client_id,
            redirect_uri=config.REDIRECT_URI,
        )

        token = oauth.fetch_token(
            token_url=url,
            code=self._auth_code,
            client_secret=self._client_secret,
        )

        return token
431962
def get_request(self):
        
        # Accept the client
        client_socket, client_address = self.socket.accept()

        if ssl is not None and self.cert_file:
            # Setup an SSL context to accept clients with a certificate
            # signed by a known chain of authority.
            # Other clients will be rejected during handshake.
            context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
            try:
                # Force a valid/signed client-side certificate
                context.verify_mode = ssl.CERT_REQUIRED

                # Load the server certificate
                context.load_cert_chain(
                    certfile=self.cert_file,
                    keyfile=self.key_file,
                    password=self.key_password,
                )

                if self.ca_file:
                    # Load the given authority chain
                    context.load_verify_locations(self.ca_file)
                else:
                    # Load the default chain if none given
                    context.load_default_certs(ssl.Purpose.CLIENT_AUTH)
            except Exception as ex:
                # Explicitly log the error as the default behaviour hides it
                _logger.error("Error setting up the SSL context: %s", ex)
                raise

            try:
                # SSL handshake
                client_stream = context.wrap_socket(
                    client_socket, server_side=True
                )
            except ssl.SSLError as ex:
                # Explicitly log the exception before re-raising it
                _logger.warning(
                    "Error during SSL handshake with %s: %s", client_address, ex
                )
                raise
        else:
            # Nothing to do, use the raw socket
            client_stream = client_socket

        return client_stream, client_address
192004
def _get_access_from_refresh(self) -> Tuple[str, float]:
        
        headers = self._get_authorization_headers()
        data = {
            'grant_type': 'refresh_token',
            'refresh_token': self.refresh_token
        }
        r = self.session.post(self.TOKEN_URL, headers=headers, data=data)
        response_data = r.json()
        return (response_data['access_token'], response_data['expires_in'])
19987
def request(self, method, url_parts, headers=None, data=None):
        
        if method in self.ALLOWED_REQUESTS:
            # add request token header
            headers = headers or {}

            # test if Oauth token
            if self.token_type == 'legacy':
                headers.update(
                    {'Token': self.api_key,
                     'User-Agent': 'optimizely-client-python/0.1.1'})
            elif self.token_type == 'oauth':
                headers.update(
                    {'Authorization': 'Bearer ' + self.api_key,
                     'User-Agent': 'optimizely-client-python/0.1.1'})
            else:
                raise ValueError(
                    '{} is not a valid token type.'.format(self.token_type))
            # make request and return parsed response
            url = urlparse.urljoin(
                self.api_base,
                '/'.join([str(url_part) for url_part in url_parts])
            )
            return self.parse_response(
                getattr(requests, method)(url, headers=headers, data=data)
            )
        else:
            raise error.BadRequestError(
                '%s is not a valid request type.' % method)
1060482
def extract_access_token(request):
    
    auth_header = request.META.get('HTTP_AUTHORIZATION', '')

    if re.compile('^[Bb]earer\s{1}.+$').match(auth_header):
        access_token = auth_header.split()[1]
    else:
        access_token = request.GET.get('access_token', '')

    return access_token
1233359
public function getRequestToken()
    {
        // Nullify any request token we already have
        $this->storage->set(null, 'request_token');
        $url = API::API_URL . self::REQUEST_TOKEN_METHOD;
        $response = $this->fetch('POST', $url, '');
        $token = $this->parseTokenString($response['body']);
        $this->storage->set($token, 'request_token');
    }
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
1207516
def get_requester(self):
        
        # TODO(abrahms): Perhaps pull this out into a factory function for
        # generating an EdxApi instance with the proper requester & credentials.
        session = requests.session()
        session.headers.update({
            'Authorization': 'Bearer {}'.format(self.credentials['access_token'])
        })

        old_request = session.request

        def patched_request(*args, **kwargs):
            """
            adds timeout param to session.request
            """
            return old_request(*args, timeout=self.timeout, **kwargs)

        session.request = patched_request
        return session
668233
def retrieve_token(self, token):
        
        headers = self.client._get_private_headers()
        endpoint = '/tokens/{}'.format(token)
        return self.client._get(self.client.URL_BASE + endpoint, headers=headers)
348453
def _get_token(self):
        """"""
        # HTTP request
        try:
            raw_res = yield from self._session.get(TOKEN_URL,
                                                   headers=self._headers,
                                                   timeout=self._timeout)
        except OSError:
            raise PyFidoError("Can not get token")
        # Research for json in answer
        content = yield from raw_res.text()
        reg_res = re.search(r"\({.*}\)", content)
        if reg_res is None:
            raise PyFidoError("Can not finf token json")
        # Load data as json
        return_data = json.loads(reg_res.group()[1:-1])
        # Get token and uuid
        token = return_data.get('result', {}).get('accessToken')
        uuid = return_data.get('result', {}).get('userData', {}).get('uuid')
        # Check values
        if token is None or uuid is None:
            raise PyFidoError("Can not get token or uuid")

        return token, uuid
1131601
def get(self, request):
        
        headers = {"Authorization": "Bearer " + self.token }
        g = requests.get(self.url + request, headers=headers)
        return json.loads(g.text)
302969
def RequestPacket(self):
        
        attr = self._PktEncodeAttributes()

        if self.authenticator is None:
            self.authenticator = self.CreateAuthenticator()

        if self.id is None:
            self.id = self.CreateID()

        header = struct.pack('!BBH16s', self.code, self.id,
            (20 + len(attr)), self.authenticator)

        return header + attr
405088
def create_data_request_token(data_request_id, opts = {})
      data, _status_code, _headers = create_data_request_token_with_http_info(data_request_id, opts)
      data
    end