final public static function fromOauth2(OAuth2\Response $oauth2Response)
    {
        $headers = [];
        foreach ($oauth2Response->getHttpHeaders() as $key => $value) {
            $headers[$key] = explode(', ', $value);
        }

        $stream = fopen('php://temp', 'r+');
        if (!empty($oauth2Response->getParameters())) {
            fwrite($stream, $oauth2Response->getResponseBody());
            rewind($stream);
        }

        return new Response(new Stream($stream), $oauth2Response->getStatusCode(), $headers);
    }