PayPal\Auth\Openid\PPOpenIdTokeninfo::createFromRefreshToken PHP Method

createFromRefreshToken() public method

Creates an Access Token from an Refresh Token.
public createFromRefreshToken ( array $params, APIContext $apiContext = null ) : PPOpenIdTokeninfo
$params array (allowed values are grant_type and scope) (required) client_id from developer portal (required) client_secret from developer portal (optional) refresh_token refresh token. If one is not passed, refresh token from the current object is used. (optional) grant_type is the Token grant type. Defaults to refresh_token (optional) scope is an array that either the same or a subset of the scope passed to the authorization request
$apiContext APIContext Optional API Context
return PPOpenIdTokeninfo
    public function createFromRefreshToken($params, $apiContext = null)
    {
        static $allowedParams = array('grant_type' => 1, 'refresh_token' => 1, 'scope' => 1);
        if (is_null($apiContext)) {
            $apiContext = new PPApiContext();
        }
        if (!array_key_exists('grant_type', $params)) {
            $params['grant_type'] = 'refresh_token';
        }
        if (!array_key_exists('refresh_token', $params)) {
            $params['refresh_token'] = $this->getRefreshToken();
        }
        $call = new PPRestCall($apiContext);
        $this->fromJson($call->execute(array(new PPOpenIdHandler()), "/v1/identity/openidconnect/tokenservice", "POST", http_build_query(array_intersect_key($params, $allowedParams)), array('Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => 'Basic ' . base64_encode($params['client_id'] . ":" . $params['client_secret']))));
        return $this;
    }