您好,
我有重定向URI的问题,当我想登录谷歌oauth2,它不会重定向我和gimme错误400:redirect_uri_mismatch
access_type=online
approval_prompt=auto
scope=https://www.googleapis.com/auth/calendar
response_type=code
redirect_uri=http://www.meetingroomapp.com/dashboard/oauth2callback.php
state=
client_id=825645938882-ftcv0fuojum9078uht1n8hpgbvp9ej3f.apps.googleusercont
index.php中有代码
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
$client->setAccessToken($_SESSION['access_token']);
SOME CODE HERE
} else {
$redirect_uri = 'http://www.meetingroomapp.com/dashboard/oauth2callback.php';
header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}
oauth2callback.php中有代码
session_start();
$client = new Google_Client();
$client->setAuthConfigFile('client_secret.json');
$client->setRedirectUri('http://www.meetingroomapp.com/dashboard/');
$client->addScope("https://www.googleapis.com/auth/calendar");
if (! isset($_GET['code'])) { //přesměrování na google server
$auth_url = $client->createAuthUrl();
header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
} else {
$client->authenticate($_GET['code']);
$_SESSION['access_token'] = $client->getAccessToken();
$redirect_uri = 'http://www.meetingroomapp.com/dashboard/';
header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}
有秘密的JSON
{"installed":{"client_id":"**ID**","project_id":"meetinroomapp","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"**SECRET**","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://www.meetingroomapp.com/dashboard/"]}}
在Google开发者控制台中,我已将http://www.meetingroomapp.com/dashboard/设为首页
答案 0 :(得分:1)
重定向不匹配。请检查您在google开发者控制台中指定的重定向是否为http://www.meetingroomapp.com/dashboard/oauth2callback.php