Refresh current expired token.

@return string
342859
public function refresh($forceForever = false, $resetClaims = false)
    {
        if ($cache = $this->getCachedToken()) {
            return $cache;
        }

        // refresh token
        $token = $this->jwt->parser()->parseToken();
        $key = md5($token);
        $refreshToken = JWTAuth::refresh($token, $forceForever, $resetClaims);

        // cache newly refreshed token
        $this->setCachedToken($key, $refreshToken);

        return $this->cachedToken;
    }
1201694
public function refresh_token() {
		if (!isset($this->auth_details['refresh_token']))
			trigger_error('Error refreshing token. There is no refresh token set on this object.', E_USER_ERROR);
		$params = array(
			'grant_type' => 'refresh_token',
			'refresh_token' => $this->auth_details['refresh_token']
		);
		return $this->_request('oauth', $params, self::OAUTH_TOKEN_URL);
	}
998968
public function getAccessToken()
    {
        if ($this->accessToken && $this->accessToken->isExpired()) {
            // The access token has expired.
            $this->accessToken = null;
        }

        if (null === $this->accessToken) {
            // Try to acquire a new access token from the server.
            $this->accessToken = $this->acquireAccessToken();
            if ($this->accessToken) {
                $this->refreshToken = $this->accessToken->getRefreshToken() ?: null;
            }
        }

        return $this->accessToken;
    }
503047
private function refreshAccessToken() {
        // Setup the params
        $params = [
            'client_id'     => $this->clientID,
            'client_secret' => $this->secret,
            'grant_type'    => 'refresh_token',
            'refresh_token' => $this->refreshToken
        ];

        // Parse the cURL result
        $this->parseAccessToken(CURL::post($this->url, $params));
    }
553007
public function findAllExpired()
    {
        $expiredBlacklistedTokens = $this->model->where('expiry', '<', Carbon::now())->get();

        return $expiredBlacklistedTokens->toArray();
    }
1035670
private function tokenExpired()
    {
        $tokenExpirationTime = $this->requestTimestamp
            + $this->data[static::RESPONSE_KEY_ACCESS_TOKEN_TTL]
            - static::TTL_CORRECTION_TIME_SEC;

        return $this->tokenExists() && time() > $tokenExpirationTime;
    }
1120372
public function expire()
    {
        if ($this->isFresh()) {
            $this->headers->set('Age', $this->getMaxAge());
            $this->headers->remove('Expires');
        }

        return $this;
    }
382764
public function get()
    {
        $this->verifyRefreshTokenExists();

        $token = $this->storage->get('refresh_token');

        return $this->encryptor->decrypt($token);
    }
835962
private function tokenCanBeRenewed()
    {
        return $this->tokenExists()
            && (time() < ($this->requestTimestamp + $this->data[self::RESPONSE_KEY_REFRESH_TOKEN_TTL]));
    }
382829
public function getAccessToken(){
		// get stored AccessToken
		$accessToken = $this->getConfig()->getStorage()->getAccessToken();
		if($accessToken !== null && $accessToken->isExpired()){
			// delete AccessToken if expired
			$this->getConfig()->getStorage()->deleteAccessToken();
			$accessToken = null;
		}
		if($accessToken !== null){
			// return AccessToken if stored and not expired
			return $accessToken;
		}
		// no AccessToken stored
		
		// get RefreshToken. May result in valid AccessToken
		$refreshToken = $this->getRefreshToken();
		if(null === $refreshToken){
			// no RefreshToken provided. need to continue polling.
			return null;
		}
		// check if AccessToken was set
		$accessToken = $this->getConfig()->getStorage()->getAccessToken();
		if($accessToken){
			return $accessToken;
		}
		// otherwise fetch new AccessToken with the RefreshToken
		return $this->getAccessTokenWithRefreshToken($refreshToken);
	}
761423
public function refresh($token, $data=null)
    {
        $data = static::formatData($data);
        
        $key = trim($token);
        
        // if shared, use same key based data
        if ($this->options['shared']) {
            $key = md5(serialize($data));
            $data['_token_'] = $token;
        }
        
        $sdata = static::getStorage()->get($key);
        
        // if has old token and not expired then refresh, else return new
        if ($sdata && time() < $sdata['_expire_time_']) {
            return ErrorInfo::success($this->options['title'] . '不需要刷新', ['token'=>$newtoken]);
        }
        
        $this->reset($token, $data);
        
        $newtoken = static::get($data);
        
        return ErrorInfo::success(['token'=>$newtoken, 'refresh_token'=>$token]);
    }
482611
public function getRefreshToken() {
        if (empty($this->refreshToken)) {
            $this->refreshToken = $this->sessionStorage->read('refresh_token');
            return $this->refreshToken;
        }
        return $this->refreshToken;
    }
158135
public function getJwtToken()
    {
        if ($this->token && $this->token->isValid()) {
            return $this->token;
        }

        $url = $this->options['token_url'];

        $requestOptions = array_merge(
            $this->getDefaultHeaders(),
            $this->auth->getRequestOptions()
        );

        $response = $this->client->request('POST', $url, $requestOptions);
        $body = json_decode($response->getBody(), true);

        $expiresIn = isset($body[$this->options['expire_key']]) ? $body[$this->options['expire_key']] : null;

        if ($expiresIn) {
            $expiration = new \DateTime('now + ' . $expiresIn . ' seconds');
        } elseif (count($jwtParts = explode('.', $body[$this->options['token_key']])) === 3
            && is_array($payload = json_decode(base64_decode($jwtParts[1]), true))
            // https://tools.ietf.org/html/rfc7519.html#section-4.1.4
            && array_key_exists('exp', $payload)
        ) {
            // Manually process the payload part to avoid having to drag in a new library
            $expiration = new \DateTime('@' . $payload['exp']);
        } else {
            $expiration = null;
        }

        $this->token = new JwtToken($body[$this->options['token_key']], $expiration);

        return $this->token;
    }
945589
public function refreshTokens()
    {
        $resource = $this->config->getEndpoint() . '/oauth2/token';

        $parameters = array(
            'grant_type' => 'refresh_token',
            'refresh_token' => $this->config->getRefreshToken(),
        );

        // Auth with basic auth
        $data = $this->client->request(
            'POST',
            $resource,
            $parameters,
            array('Authorization' => 'Basic ' . base64_encode($this->config->getClientId() . ':' . $this->config->getClientSecret()))
        );

        // Overwrite $this->config with new settings
        $this->config->setAccessToken($data['access_token']);
        $this->config->setRefreshToken($data['refresh_token']);

        // Return token data
        return $data;
    }
901038
public function isAccessTokenExpired() {
    if (null == $this->token) {
      return true;
    }

    // If the token is set to expire in the next 30 seconds.
    $expired = ($this->token['created']
        + ($this->token['expires_in'] - 30)) < time();

    return $expired;
  }
703044
def refresh_token(self):
        
        self.token = self.oauth.refresh_token(self.access_token_url, refresh_token=self.get_refresh_token())
        self.access_token = self.token.get("access_token")
1219364
public function refresh()
    {
        $tokenURL = $this->credentials['loginURL'] . '/services/oauth2/token';
        $authToken = $this->getAuthToken($tokenURL);

        $this->tokenRepo->put($authToken);
    }