Get an access_token from OAuth provider.

        :returns: (access_token, provider_data)
508667
async def get_access_token(self, code, loop=None, redirect_uri=None, **payload):
        
        # Possibility to provide REQUEST DATA to the method
        payload.setdefault('grant_type', 'authorization_code')
        payload.update({'client_id': self.client_id, 'client_secret': self.client_secret})

        if not isinstance(code, str) and self.shared_key in code:
            code = code[self.shared_key]
        payload['refresh_token' if payload['grant_type'] == 'refresh_token' else 'code'] = code

        redirect_uri = redirect_uri or self.params.get('redirect_uri')
        if redirect_uri:
            payload['redirect_uri'] = redirect_uri

        self.access_token = None
        data = await self.request('POST', self.access_token_url, data=payload, loop=loop)

        try:
            self.access_token = data['access_token']

        except KeyError:
            self.logger.error(
                'Error when getting the access token.\nData returned by OAuth server: %r',
                data,
            )
            raise web.HTTPBadRequest(reason='Failed to obtain OAuth access token.')

        return self.access_token, data
1068322
def request_token(self):
        
        client = OAuth1(
            client_key=self._server_cache[self.client.server].key,
            client_secret=self._server_cache[self.client.server].secret,
            callback_uri=self.callback,
        )

        request = {"auth": client}
        response = self._requester(
            requests.post,
            "oauth/request_token",
            **request
        )

        data = parse.parse_qs(response.text)
        data = {
            'token': data[self.PARAM_TOKEN][0],
            'token_secret': data[self.PARAM_TOKEN_SECRET][0]
        }

        return data
113477
def get_oauth_token_secret_name(self, provider):
        
        for _provider in self.oauth_providers:
            if _provider["name"] == provider:
                return _provider.get("token_secret", "oauth_token_secret")
699474
def get_access_token(options = {}, *arguments)
      response = consumer.token_request(consumer.http_method, (consumer.access_token_url? ? consumer.access_token_url : consumer.access_token_path), self, options, *arguments)
      OAuth::AccessToken.from_hash(consumer, response)
    end
645634
def get_access_token(self):
        
        try:
            credentials = OAuth2Credentials.from_json(
                self.credentials_store[g.oidc_id_token['sub']])
            return credentials.access_token
        except KeyError:
            logger.debug("Expired ID token, credentials missing",
                         exc_info=True)
            return None
154710
def get_access_token(self):
        
        if self.is_access_token_expired():

            if is_debug_enabled():
                debug('requesting new access_token')

            token = get_access_token(username=self.username,
                                     password=self.password,
                                     client_id=self.client_id,
                                     client_secret=self.client_secret,
                                     app_url=self.app_url)

            # lets make sure to refresh before we're halfway to expiring
            self.expires_at = time.time() + token['expires_in']/2
            self.access_token = token['access_token']

        return self.access_token
884472
def request_access_token(self, params):
        
        return self.client().request(self.access_token_url, method="POST", body=urllib.urlencode(params), headers={'Content-Type':'application/x-www-form-urlencoded'})
1316578
def _get_access_token(self):
        
        err = 'Failed to contact IAM token service'
        try:
            resp = super(IAMSession, self).request(
                'POST',
                self._token_url,
                auth=self._token_auth,
                headers={'Accepts': 'application/json'},
                data={
                    'grant_type': 'urn:ibm:params:oauth:grant-type:apikey',
                    'response_type': 'cloud_iam',
                    'apikey': self._api_key
                }
            )
            err = response_to_json_dict(resp).get('errorMessage', err)
            resp.raise_for_status()

            return response_to_json_dict(resp)['access_token']

        except KeyError:
            raise CloudantException('Invalid response from IAM token service')

        except RequestException:
            raise CloudantException(err)
98399
def retrieve_token(self):
        

        if self.authorization_code:
            request_param = {
                "client_id": self.client_id,
                "client_secret": self.client_secret,
                "redirect_uri": self.redirect_uri,
                "code": self.authorization_code
                }

            if self._extra_token_params:
                request_param.update(self._extra_token_params)

            content_length = len(urlencode(request_param))
            headers = {
                'Content-Length': str(content_length),
                'Content-Type': 'application/x-www-form-urlencoded'
                }
        
            r = requests.post(self.token_uri, data=request_param,
                              headers=headers)
            jsondata = json.loads(r.text)
            self.access_token = jsondata
            return self.access_token

        else:
            print("authorization code is required before getting accesss token")
            print("Please call retrieve_authorization_code() beforehand")
691454
def get_login_info(self, auth_code, provider_access_token=None):
        
        return self._post(
            'service/get_login_info',
            params={
                'provider_access_token': provider_access_token,
            },
            data={
                'auth_code': auth_code,
            }
        )
648267
def complete(self, GET):
        
        if 'error' in GET:
            raise OAuthError(
                _("Received error while obtaining access token from %s: %s") % (
                    self.access_token_url, GET['error']))
        return self.get_access_token(code=GET.get('code'))
1318029
def obtain_access_token(self):
        
        if self.oauth_version != 2:
            raise TwythonError('This method can only be called when your \
                               OAuth version is 2.0.')

        data = {'grant_type': 'client_credentials'}
        basic_auth = HTTPBasicAuth(self.app_key, self.app_secret)
        try:
            response = self.client.post(self.request_token_url,
                                        data=data, auth=basic_auth)
            content = response.content.decode('utf-8')
            try:
                content = content.json()
            except AttributeError:
                content = json.loads(content)
                access_token = content['access_token']
        except (KeyError, ValueError, requests.exceptions.RequestException):
            raise TwythonAuthError('Unable to obtain OAuth 2 access token.')
        else:
            return access_token
236787
def get_auth_token(cls):
        
        if 'Authorization' not in f_request.headers:
            raise ValueError("Missing Authorization Bearer in headers")
        data = f_request.headers['Authorization'].encode('ascii', 'ignore')
        return str.replace(str(data), 'Bearer ', '').strip()
204149
def get_token_info(self):
        
        response = requests.get(
            self._format_url(OAUTH2_ROOT + 'token_info', {
                'token': self.creds['access_token']
            }))
        data = response.json()
        if response.status_code != 200:
            raise _token_error_from_data(data)
        else:
            return data
547205
def get_provider_token(self, provider_secret):
        
        return self._post(
            'service/get_provider_token',
            data={
                'corpid': self._client.corp_id,
                'provider_secret': provider_secret,
            }
        )
384021
def get_access_token(self):
        
        if self.access_token is None:
            request_token = self._get_rt_from_session()
            oauth = OAuth1(
                self.consumer_key,
                client_secret=self.consumer_secret,
                resource_owner_key=request_token['oauth_token'],
                resource_owner_secret=request_token['oauth_token_secret'])
            at_url = self.access_token_url
            # Passing along oauth_verifier is required according to:
            # http://groups.google.com/group/twitter-development-talk/browse_frm/thread/472500cfe9e7cdb9#
            # Though, the custom oauth_callback seems to work without it?
            oauth_verifier = get_request_param(self.request, 'oauth_verifier')
            if oauth_verifier:
                at_url = at_url + '?' + urlencode(
                    {'oauth_verifier': oauth_verifier})
            response = requests.post(url=at_url, auth=oauth)
            if response.status_code not in [200, 201]:
                raise OAuthError(
                    _('Invalid response while obtaining access token'
                      ' from "%s".') % get_token_prefix(
                          self.request_token_url))
            self.access_token = dict(parse_qsl(response.text))

            self.request.session['oauth_%s_access_token' % get_token_prefix(
                self.request_token_url)] = self.access_token
        return self.access_token
566974
def get_application_access_token(application_id, application_secret_key, api_version=None):
    
    graph = GraphAPI(version=api_version)

    response = graph.get(
        path='oauth/access_token',
        client_id=application_id,
        client_secret=application_secret_key,
        grant_type='client_credentials'
    )

    try:
        data = parse_qs(response)

        try:
            return data['access_token'][0]
        except KeyError:
            raise GraphAPI.FacebookError('No access token given')
    except AttributeError:  # api_version >= 2.3 returns a dict
        return response['access_token'], None