Zoom API - 请求检查电子邮件不起作用

Zoom API - Request to check email does not work

我正在尝试使用 PHP 和 Oauth2 使用 Zoom 的 API。我能够连接到应用程序并使用通用库 oauth2-client 获取令牌。但是,当我尝试提出一个简单的请求时,我收到一个错误,说电子邮件丢失了。这是我的代码:

<?php  

session_start();

require __DIR__ . '/vendor/autoload.php';

$provider = new \League\OAuth2\Client\Provider\GenericProvider([
    'clientId'                => 'meuclientid',
    'clientSecret'            => 'meuclientsecret',
    'redirectUri'             => 'http://localhost/teste_oauth2/',
    'urlAuthorize'            => 'https://zoom.us/oauth/authorize',
    'urlAccessToken'          => 'https://zoom.us/oauth/token',
    'urlResourceOwnerDetails' => 'https://api.zoom.us/v2/users/me'
]);


// If we don't have an authorization code then get one
if (!isset($_GET['code'])) {    
    $authorizationUrl = $provider->getAuthorizationUrl();

    // Get the state generated for you and store it to the session.
    $_SESSION['oauth2state'] = $provider->getState();

    // Redirect the user to the authorization URL.
    header('Location: ' . $authorizationUrl);
    exit;

// Check given state against previously stored one to mitigate CSRF attack
} 
elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {

    unset($_SESSION['oauth2state']);
    exit('Invalid state');

} else {

    try {

        // Try to get an access token using the authorization code grant.
        $accessToken = $provider->getAccessToken('authorization_code', [
            'code' => $_GET['code']
        ]);

        $request = $provider->getAuthenticatedRequest(
            'GET',
            'https://api.zoom.us/v2/users/email',
            $accessToken,
            ['email' => 'meuemail@gmail.com']
        );


        var_dump($provider->getResponse($request));
        die('aqui');

    } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {

        // Failed to get the access token or user details.
        echo $e->getMessage();
        exit;

    }
}

?>

如您所见,我正在传递有关请求的电子邮件。但我收到致命错误:未捕获 GuzzleHttp\Exception\ClientException:客户端错误:GET https://api.zoom.us/v2/users/email 导致 400 错误请求响应:{"code":300,"message":"Email is required."}

谁能帮帮我?

您正在使用

['email' => 'meuemail@gmail.com']

这在函数 $provider->getAuthenticatedRequest

中是不允许的

您需要将其与现有的 URL:

        $request = $provider->getAuthenticatedRequest(
            'GET',
            'https://api.zoom.us/v2/users/email?email=meuemail@gmail.com',
            $accessToken
        );

希望对您有所帮助..!!

缩放API参考:https://marketplace.zoom.us/docs/api-reference/zoom-api/users/useremail

OAuth 参考:https://github.com/thephpleague/oauth2-client