Refresh or acquire access_token.
332972
def auth_get_token(self, check_state=True):
		''
		res = self.auth_access_data_raw = yield self._auth_token_request()
		defer.returnValue(self._auth_token_process(res, check_state=check_state))
227705
def refresh_access_token(self, refresh_token, redirect_uri=None):
        '''
        
        '''
        redirect = redirect_uri or self._redirect_uri
        resp_text = _http('POST', 'https://graph.qq.com/oauth2.0/token',
                          refresh_token=refresh_token,
                          client_id=self._client_id, client_secret=self._client_secret,
                          redirect_uri=redirect, grant_type='refresh_token')
        return self._parse_access_token(resp_text)
730304
def refresh_access_token(self, refresh_token):
        
        res = self._get(
            'sns/oauth2/refresh_token',
            params={
                'appid': self.app_id,
                'grant_type': 'refresh_token',
                'refresh_token': refresh_token
            }
        )
        self.access_token = res['access_token']
        self.open_id = res['openid']
        self.refresh_token = res['refresh_token']
        self.expires_in = res['expires_in']
        return res
719938
def refresh_authorization(self):
        
        response = self.request_handler.post(
            endpoint='oauth/token',
            omit_api_version=True,
            data={
                'grant_type': 'refresh_token',
                'client_id': self.auth.client_id,
                'client_secret': self.auth.client_secret,
                'refresh_token': self.auth.refresh_token,
            }
        )
        data = response.json()
        token_expiration = (datetime.datetime.utcnow() + datetime.timedelta(seconds=data['expires_in']))
        self.auth.update(
            token_expiration=token_expiration,
            access_token=data['access_token'],
            refresh_token=data['refresh_token'],
        )
        return {
            'access_token': self.auth.access_token,
            'refresh_token': self.auth.refresh_token,
            'token_expiration': format_event_time(self.auth.token_expiration),
        }
1076842
def refresh(self):
        ""

        # Construct the credentials for the verification request
        oauth = OAuth1(
            self.consumer_key,
            client_secret=self.consumer_secret,
            resource_owner_key=self.oauth_token,
            resource_owner_secret=self.oauth_token_secret,
            rsa_key=self.rsa_key,
            signature_method=self._signature_method
        )

        # Make the verification request, getting back an access token
        headers = {'User-Agent': self.user_agent}
        params = {'oauth_session_handle': self.oauth_session_handle}
        response = requests.post(url=self.base_url + ACCESS_TOKEN_URL,
                params=params, headers=headers, auth=oauth)
        self._process_oauth_response(response)
291764
def access_token(self):
        
        access = AccessToken()

        # Use instantiation time of refresh token as relative timestamp for
        # access token "exp" claim.  This ensures that both a refresh and
        # access token expire relative to the same time if they are created as
        # a pair.
        access.set_exp(from_time=self.current_time)

        no_copy = self.no_copy_claims
        for claim, value in self.payload.items():
            if claim in no_copy:
                continue
            access[claim] = value

        return access
401357
def use_refresh_token(self, refresh_token, scope=None):
        # type (str, Optional[List[str]]) -> Tuple[se_leg_op.access_token.AccessToken, Optional[str]]
        

        if refresh_token not in self.refresh_tokens:
            raise InvalidRefreshToken('{} unknown'.format(refresh_token))

        refresh_token_info = self.refresh_tokens[refresh_token]
        if 'exp' in refresh_token_info and refresh_token_info['exp'] < int(time.time()):
            raise InvalidRefreshToken('{} has expired'.format(refresh_token))

        authz_info = self.access_tokens[refresh_token_info['access_token']]

        if scope:
            if not requested_scope_is_allowed(scope, authz_info['granted_scope']):
                logger.debug('trying to refresh token with superset scope, requested_scope=%s, granted_scope=%s',
                             scope, authz_info['granted_scope'])
                raise InvalidScope('Requested scope includes non-granted value')
            scope = ' '.join(scope)
            logger.debug('refreshing token with new scope, old_scope=%s -> new_scope=%s', authz_info['scope'], scope)
        else:
            # OAuth 2.0: scope: "[...] if omitted is treated as equal to the scope originally granted by the resource owner"
            scope = authz_info['granted_scope']

        new_access_token = self._create_access_token(authz_info['sub'], authz_info[self.KEY_AUTHORIZATION_REQUEST],
                                                     authz_info['granted_scope'], scope)

        new_refresh_token = None
        if self.refresh_token_threshold \
                and 'exp' in refresh_token_info \
                and refresh_token_info['exp'] - int(time.time()) < self.refresh_token_threshold:
            # refresh token is close to expiry, issue a new one
            new_refresh_token = self.create_refresh_token(new_access_token.value)
        else:
            self.refresh_tokens[refresh_token]['access_token'] = new_access_token.value

        logger.debug('refreshed tokens, new_access_token=%s new_refresh_token=%s old_refresh_token=%s',
                     new_access_token, new_refresh_token, refresh_token)
        return new_access_token, new_refresh_token
447111
def refresh():
    
    old_token = guard.read_token_from_header()
    new_token = guard.refresh_jwt_token(old_token)
    ret = {'access_token': new_token}
    return flask.jsonify(ret), 200
747633
protected function refreshAccessTokenIfRequired(): bool
    {
        if (!$this->client->isAccessTokenExpired()) {
            return false;
        }

        $this->logger->info('The access token is expired; refreshing the token');

        try {
            $accessToken = $this->client->fetchAccessTokenWithRefreshToken();
        } catch (\Exception $exception) {
            throw new \RuntimeException('Failed to refresh the token: '.$exception->getMessage());
        }
        if (isset($accessToken['error'])) {
            throw new \RuntimeException('Google has declined refreshing the token: '.($accessToken['error_description'] ?? '(no message)'));
        }

        return true;
    }
681205
protected function refreshToken()
    {
        $token = $this->authorization->getApi()
                                     ->getAuthorizerToken(
                                         $this->authorization->getAuthorizerCorpId(),
                                         $this->authorization->getAuthorizerPermanentCode()
                                     );

        $this->authorization->setAuthorizerAccessToken($token['access_token'], $token['expires_in'] - 1500);

        return $token['access_token'];
    }
1324736
def refresh_access_token(self):
        
        if self.client_secret is None:
            raise Exception("client_secret must be set to execute "
                            "refresh_access_token.")
        if self.refresh_token is None:
            raise Exception("refresh_token must be set to execute "
                            "refresh_access_token.")
        params = {'client_id': self.client_id,
                  'client_secret': self.client_secret,
                  'grant_type': 'refresh_token',
                  'refresh_token': self.refresh_token}
        result = self._send_request(REFRESH_URL.format(self._base_url),
                                    params=params, method='POST',
                                    data_field=None)
        self.access_token = result['access_token']
        return self.access_token
83996
def refresh_mrrt(responses, resource)
      logger.verbose("Attempting to obtain access token for #{resource} by " \
                     "refreshing 1 of #{responses.count(&:mrrt?)} matching " \
                     'MRRTs.')
      responses.each do |response|
        if response.mrrt?
          refresh_response = response.refresh(resource)
          return refresh_response if add(refresh_response)
        end
      end
      nil
    end
1256532
public function updateRefreshToken(): void
    {

        tap($this->token, function ($token) {

            // If no API call was made, the client would never have
            // been instantiated and auth information never updated.
            if (is_null($this->client) || $this->public_call)
                return;

            $last_auth = $this->client->getAuthentication();

            $token->token = $last_auth->access_token ?? '-';
            $token->expires_on = $last_auth->token_expires;

            $token->save();
        });
    }
404602
def refresh_token(self, arguments):
        

        new_access_token = None

        auth = ExistAuth(self.client_id, self.client_secret)
        resp = auth.refresh_token(self.access_token)
        if auth.token:
            new_access_token = auth.token['access_token']
            print('OAuth token refreshed: %s' % new_access_token)
            self.write_config(new_access_token)
        else:
            print('ERROR: We were unable to refresh the OAuth token | %s' % json.dumps(resp))
257235
public static function refreshToken(AccessToken $token, $params = null)
    {
        if ($token->expires_at > new \DateTime()) {
            return $token;
        }

        $requestor = new ApiRequestor(Sumup::$connectBase, true);
        $params = [
            'grant_type' => 'refresh_token',
            'client_id' => self::_getConnectParam('client_id', $params),
            'client_secret' => self::_getConnectParam('client_secret', $params),
            'refresh_token' => $token->refresh_token
        ];
        $response = $requestor->request('post', '/token', $params);

        if ($response->raw->getStatusCode() !== 200) {
            throw new Error\AuthenticationError('Token request error');
        }

        return new AccessToken($response);
    }
514523
def get_access_token(self, refresh_token):
        

        token = requests.post(GOOGLE_OAUTH2_TOKEN_URL, data=dict(
            refresh_token=refresh_token,
            grant_type='refresh_token',
            client_id=self.client_id,
            client_secret=self.client_secret,
        )).json()

        if not token or token.get('error'):
            return

        return token
647791
def access_token(self) -> str:
        
        if self._token_expires_at < time.time() + self._REFRESH_THRESHOLD:
            self.request_token()

        return self._token["access_token"]