doufei1893 2015-12-10 12:46
浏览 119

Redirect_uri_mismatch不起作用

Hello,
i have issues with redirect URI, when i want to log in google oauth2, it doesnt redirect me and gimme Error 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

There is code in 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));
}

There is code in 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));
}

There is secret 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/"]}}

In Google developer console i have set http://www.meetingroomapp.com/dashboard/ as homepage

  • 写回答

1条回答 默认 最新

  • dourao3960 2015-12-14 18:15
    关注

    redirect mismatch happens when the redirect uri you specified in you request doesnt match the one you specified in google developer console.so check if the the redirect uri you specfied in google developer console is http://www.meetingroomapp.com/dashboard/oauth2callback.php

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题