网页授权获取用户信息:第三步(非必须)
由于access_token拥有较短的有效期，当access_token超时后，可以使用refresh_token进行刷新，refresh_token拥有较长的有效期（7天、30天、60天、90天），当refresh_token失效的后，需要用户重新授权。
@param $refreshToken
@param string $grantType
@return array|bool
543057
public function refreshOauth2AccessToken($refreshToken, $grantType = 'refresh_token')
    {
        $result = $this->httpGet(self::WECHAT_OAUTH2_ACCESS_TOKEN_REFRESH_URL . http_build_query([
            'appid' => $this->appId,
            'grant_type' => $grantType,
            'refresh_token' => $refreshToken
        ]));
        return isset($result['errmsg']) ? false : $result;
    }
342971
function refreshToken($accessToken, $sessionHandle) {
		$code = $this->request ( 'GET', $this->url ( 'AccessToken', '' ), array (
				'oauth_token' => $accessToken,
				'oauth_session_handle' => $sessionHandle 
		) );
		if ($this->response ['code'] == 200) {
			
			$response = $this->extract_params ( $this->response ['response'] );
			
			return $response;
		} else {
			$this->response ['helper'] = "TokenFatal";
			return $this->response;
		}
	}
706627
protected function prepareTokenResponse(
        AccessToken $accessToken,
        RefreshToken $refreshToken = null,
        bool $useRefreshTokenScopes = false
    ): ResponseInterface {
        $owner = $accessToken->getOwner();
        $scopes = $useRefreshTokenScopes ? $refreshToken->getScopes() : $accessToken->getScopes();

        $responseBody = [
            'access_token' => $accessToken->getToken(),
            'token_type' => 'Bearer',
            'expires_in' => $accessToken->getExpiresIn(),
            'scope' => implode(' ', $scopes),
            'owner_id' => $owner ? $owner->getTokenOwnerId() : null,
        ];

        if (null !== $refreshToken) {
            $responseBody['refresh_token'] = $refreshToken->getToken();
        }

        return new Response\JsonResponse(array_filter($responseBody));
    }
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;
    }
270980
public function checkRestrictedGrantType($clientUuid, $grantType)
    {
        $client = $this->getClientDataMapper()->findByUuid($clientUuid);

        if (! $client instanceof Entity\Client) {
            return false;
        }

        $clientGrantTypes = $client->getGrantTypes();

        if (empty($clientGrantTypes)) {
            return true;
        }

        return in_array($grantType, $clientGrantTypes);
    }
1119682
public function refreshToken($refreshToken)
	{
		$response = $this->http->get($this->getUrl('action/openapi/token'), array(
			'client_id'		=>	$this->appid,
			'client_secret'	=>	$this->appSecret,
			'grant_type'	=>	'refresh_token',
			'redirect_uri'	=>	$this->getRedirectUri(),
			'refresh_token'	=>	$refreshToken,
			'dataType'		=>	'json',
		));
		$this->result = $response->json(true);
		if(!isset($this->result['error']))
		{
			return $this->accessToken = $this->result['access_token'];
		}
		else
		{
			throw new ApiException(isset($this->result['error_description']) ? $this->result['error_description'] : '', $response->httpCode());
		}
	}
205615
public function getRefreshToken($refresh_token)
    {
        return isset($this->refreshTokens[$refresh_token]) ? $this->refreshTokens[$refresh_token] : false;
    }
852582
public function refreshAccessToken(AccessToken $token = null):AccessToken{

		if($token === null){
			$token = $this->storage->getAccessToken($this->serviceName);
		}

		$refreshToken = $token->refreshToken;

		if(empty($refreshToken)){

			if(!$this instanceof AccessTokenForRefresh){
				throw new ProviderException(sprintf('no refresh token available, token expired [%s]', date('Y-m-d h:i:s A', $token->expires)));
			}

			$refreshToken = $token->accessToken;
		}

		$body = [
			'client_id'     => $this->options->key,
			'client_secret' => $this->options->secret,
			'grant_type'    => 'refresh_token',
			'refresh_token' => $refreshToken,
			'type'          => 'web_server',
		];

		$request = $this->requestFactory
			->createRequest('POST', $this->refreshTokenURL ?? $this->accessTokenURL)
			->withHeader('Content-Type', 'application/x-www-form-urlencoded')
			->withHeader('Accept-Encoding', 'identity')
			->withBody($this->streamFactory->createStream(http_build_query($body, '', '&', PHP_QUERY_RFC1738)))
		;

		foreach($this->authHeaders as $header => $value){
			$request = $request->withAddedHeader($header, $value);
		}

		$newToken = $this->parseTokenResponse($this->http->sendRequest($request));

		if(empty($newToken->refreshToken)){
			$newToken->refreshToken = $refreshToken;
		}

		$this->storage->storeAccessToken($this->serviceName, $newToken);

		return $newToken;
	}
1339223
public function getOauth2AccessToken($code, $grantType = 'authorization_code')
    {
        $result = $this->httpGet(self::WECHAT_OAUTH2_ACCESS_TOKEN_URL . http_build_query([
            'appid' => $this->appId,
            'secret' => $this->appSecret,
            'code' => $code,
            'grant_type' => $grantType
        ]));
        return isset($result['errmsg']) ? false : $result;
    }
719295
def refresh_token(self, refresh_token):
        

        response = requests.post('%saccess_token' % OAUTH_URL, {
                                 'refresh_token': refresh_token,
                                 'grant_type': 'refresh_token',
                                 'client_id': self.client_id,
                                 'client_secret': self.client_secret
                                 })
        resp = json.loads(response.content)

        if 'access_token' in resp:
            self.token = resp['access_token']

        return resp
329449
public function hasGrantType($grantType)
    {
        $grants = explode(',', $this->Grants);

        return !empty($grants) && in_array($grantType, $grants);
    }
507383
public function setRefreshToken($refreshToken = null)
    {
        $this->refreshToken = null === $refreshToken
            ? bin2hex(openssl_random_pseudo_bytes(64))
            : $refreshToken;

        return $this;
    }
575393
public function getBearerToken($grantType = 'client_credentials')
    {
        $request = $this->createRequest('/oauth2/token');
        $request->setPostParameter('grant_type', $grantType);
        $this->signRequest($request, new BasicToken());

        return $this->createBearerToken($this->sendRequest($request));
    }
1370482
protected boolean isRefreshTokenSupported(String grantType, Set<String> scope) {
        if (!isRestrictRefreshGrant) {
            return GRANT_TYPE_AUTHORIZATION_CODE.equals(grantType) ||
                GRANT_TYPE_PASSWORD.equals(grantType) ||
                GRANT_TYPE_USER_TOKEN.equals(grantType) ||
                GRANT_TYPE_REFRESH_TOKEN.equals(grantType) ||
                GRANT_TYPE_SAML2_BEARER.equals(grantType);
        } else {
            return scope.contains(UAA_REFRESH_TOKEN);
        }
    }
4977
public function getRefreshToken($refresh_token)
    {
        return isset($this->refreshTokens[$refresh_token]) ? $this->refreshTokens[$refresh_token] : null;
    }
82864
public function getOauthRefreshToken($refresh_token)
    {
        $result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::OAUTH_REFRESH_URL . "appid={$this->appid}&grant_type=refresh_token&refresh_token={$refresh_token}");
        if ($result) {
            $json = json_decode($result, true);
            if (empty($json) || !empty($json['errcode'])) {
                $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505';
                $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容！';
                Tools::log("WechatOauth::getOauthRefreshToken Fail.{$this->errMsg} [{$this->errCode}]", "ERR - {$this->appid}");
                return false;
            }
            return $json;
        }
        return false;
    }
545531
private String getRefreshToken(Token accessToken) {
    JSONObject rawJson = JSONObject.fromObject(accessToken.getRawResponse());
    return rawJson.getString("refresh_token");
  }