Redirect_uri_mismatch不起作用



你好,
我的重定向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/"]}}

在谷歌开发者控制台中,我设置了http://www.meetingroomapp.com/dashboard/作为主页

当您在请求中指定的重定向uri与您在谷歌开发者控制台中指定的不匹配时,会发生重定向不匹配。因此,请检查您在谷歌开发人员控制台中指定了的重定向uri是否为http://www.meetingroomapp.com/dashboard/oauth2callback.php

相关内容

  • 没有找到相关文章

最新更新