【发布时间】:2019-10-08 21:06:05
【问题描述】:
我正在使用 google/apiclient 开发 Yii2。 我不断收到“错误:redirect_uri_mismatch”
- 我已将“http://localhost”设置为授权重定向
- 尝试使用“https://localhost”
- 尝试使用“https://localhost/”
- 等待超过 1 小时以使更改生效
似乎没有任何效果,有什么见解吗?
我的代码没什么特别的:
$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('my_mail@not.relevant');
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
【问题讨论】:
标签: php google-api google-oauth google-api-php-client google-developers-console