OAuth是否允许本地主机进行调试? [重复]

问题描述 投票:2回答:2

此问题已经在这里有了答案:

我正在使用google / apiclient开发Yii2。我不断收到“错误:redirect_uri_mismatch”

似乎无用,有见识吗?

我的代码没什么特别的:

$session = Yii::$app->session;

    $gClient = new Google_Client();
    $pathToSecret = Yii::getAlias('@app/auth/gCalendar_ClientSecret.json');
    $gClient->setAuthConfig($pathToSecret);
    $gClient->addScope(Google_Service_Calendar::CALENDAR_EVENTS_READONLY);
    $gClient->setLoginHint('[email protected]');
    if ($session->has('oauth_access_token')) {
        $gClient->setAccessToken($session->get('oauth_calendar_access_token'));
        //do something else
    } else {
        $redirectUri = Url::toRoute('/calendar/oauth-response', 'http');
        $gClient->setRedirectUri($redirectUri);
        return $gClient->createAuthUrl();
    }

基于错误,请求似乎正常:

请求中的重定向URI,http://localhost/ascoSL/public_html/sl/index.php?r=calendar%2Foauth-响应,与为OAuth客户端授权的响应不匹配。更新授权的重定向URI,请访问:https://console.developers.google.com/apis/credentials/oauthclient/XXXXX

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS94bmFxQS5wbmcifQ==” alt =“请参阅我的Google配置的捕获”>

我正在使用google / apiclient开发Yii2。我不断收到“错误:redirect_uri_mismatch”,我已将“ http:// localhost”设置为授权重定向尝试过“ https:// localhost”尝试过“ https:// ...

php google-api google-oauth google-api-php-client google-developers-console
2个回答
2
投票
您需要在Google API控制台中注册API端点:

0
投票
好,因此必须注册EXACT绝对路径,我假设将允许子目录。一旦注册了完整的URI,重定向就可以正常工作。感谢SweetChillyPhilly提供的链接。

-1
投票
好,因此必须注册EXACT绝对路径,我假设将允许子目录。一旦注册了完整的URI,重定向就可以正常工作。感谢SweetChillyPhilly提供的链接。
© www.soinside.com 2019 - 2024. All rights reserved.