- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我使用 google plus api 获取用户信息的 php 代码。我已经取消设置访问 token ,以防用户单击注销但仍然注销不起作用。一旦我获得任何用户的信息,然后在注销并再次连接后,我仍然获得相同的用户信息,并且无法选择使用不同的电子邮件 ID 登录。
<?php
error_reporting(E_ERROR | E_PARSE);
include_once "templates/base.php";
session_start();
set_include_path("google-api-php-client-master/src/" . PATH_SEPARATOR . get_include_path());
require_once 'Google/Client.php';
require_once 'Google/Service/Plus.php';
require_once 'Google/Service/Oauth2.php';
$client_id = '554944507188-jvl2lg6l70dfmee1qad8rguircdfesba.apps.googleusercontent.com';
$client_secret = '-kcfgfqWdhk9sDNOO8LC9N6A';
$redirect_uri = 'http://localhost:81/googleplus/redirect.php';
$client = new Google_Client();
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setRedirectUri($redirect_uri);
$client->setDeveloperKey('AIzaSyCWdr3JGvgOZ0lPX9R6hJP4Y00J-R2Ksgg');
$plus = new Google_Service_Plus($client);
$google_oauthV2 = new Google_Service_Oauth2($client);
$client->setScopes('https://www.googleapis.com/auth/plus.login');
$client->setScopes('email');
/************************************************
If we're logging out we just need to clear our
local access token in this case
************************************************/
if (isset($_REQUEST['logout'])) {
unset($_SESSION['access_token']);
}
/************************************************
If we have a code back from the OAuth 2.0 flow,
we need to exchange that with the authenticate()
function. We store the resultant access token
bundle in the session, and redirect to ourself.
************************************************/
if (isset($_GET['code'])) {
$client->authenticate($_GET['code']);
$_SESSION['access_token'] = $client->getAccessToken();
$redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}
/************************************************
If we have an access token, we can make
requests, else we generate an authentication URL.
************************************************/
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
$client->setAccessToken($_SESSION['access_token']);
} else {
$authUrl = $client->createAuthUrl();
}
/************************************************
If we're signed in we can go ahead and retrieve
the ID token, which is part of the bundle of
data that is exchange in the authenticate step
- we only need to do a network call if we have
to retrieve the Google certificate to verify it,
and that can be cached.
************************************************/
if ($client->getAccessToken()) {
$_SESSION['access_token'] = $client->getAccessToken();
$token_data = $client->verifyIdToken()->getAttributes();
$user = $google_oauthV2->userinfo->get();
$me = $plus->people->get('me');
}
echo pageHeader("GOOGLE+ API for Information Retrival");
if (
$client_id == ' '
|| $client_secret == ' '
|| $redirect_uri == ' ') {
echo missingClientSecretsWarning();
}
?>
<div class="box">
<div class="request">
<?php if (isset($authUrl)): ?>
<a class='login' href='<?php echo $authUrl; ?>'>Connect Me!</a>
<?php else: ?>
<a class='logout' href='index.php?logout'>Logout</a>
<?php endif ?>
</div>
</div>
最佳答案
这个怎么样?
if (isset($_REQUEST['logout'])) {
unset($_SESSION['access_token']);
header('Location: https://www.google.com/accounts/Logout?continue=https://appengine.google.com/_ah/logout?continue=http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}
关于php - 未在 php 中使用 google+ api 注销,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24359324/
我正在进行 Twitter 集成。 我不知道如何退出 Twitter。 我正在使用以下代码尝试注销...但它只是删除了 token : try {
我可以使用我的站点和 phpBB3 的集成登录系统登录。我不能 注销...我尝试破坏 session ,或使用 ->logout(); 我登录为: $phpBBusername = $_SES
我目前正在学习 firebase facebook auth,但似乎 firebase 不提供 facebook logout api? 因为我在 firefeed.io 上注销,但它并没有注销 fa
环境 Richfaces 3.3.3 JSF 1.2 站点记录器 要求 用户输入所需的申请地址。 Siteminder 拦截并询问用户名和密码。客户提供凭据。客户使用应用程序并单击注销/退出按钮。应用
我喜欢从 Azure 广告 B2C 中注销我的 Web 应用程序。我尝试了以下示例 https://www.janaks.com.np/azure-ad-identity-provider-in-as
通过使用 here 中的 Fitbit 文档。我已在我的应用程序中成功通过 token 过期时间 expires_in=604800 进行 Fitbit 身份验证。我对如何从登录帐户注销感到困惑。是否
我有一个使用 Oauth 2 与 Facebook 集成的应用程序。 我可以使用 FB 授权并很好地查询他们的 REST 和图形 API,但是当我授权时,一个事件的浏览器 session 是使用 FB
在我的应用程序中,我有一个将 BroadcastReceiver 注册到 onStart() 方法中的服务: public void onStart() { if(something....)
我有一个 div 标签,可以说“mydivTag” 它下面有一个子节点,ID为“childID” 我想删除/取消注册/任何“childID”,然后重新创建具有相同 ID“childID”的不同节点 如
我有一个 asp.net 应用程序,我正在使用 FormsAuthantication。当用户关闭页面时,位于 Global.asax Session_End 中的代码被执行:FormsAuthant
我的应用程序的结构如图所示。 在我的 ProfileViewController(选项卡之一)中,有一个注销按钮。 我想弹出回到 RegisterViewController。 如果用户已经注册,我将
有没有办法注销在 php 中完成的摘要式身份验证。 我试过 unset($_SERVER["PHP_AUTH_DIGEST"]);但它不会要求重新登录。我知道如果我关闭浏览器它就会工作,这是我的功能。
我的问题是捕获用户注销。我的代码是: public function onAuthenticationFailure(Request $request, AuthenticationExceptio
我下面的代码是应用程序的 OnClick 注销方法。目前它所做的只是将用户返回到登录页面,但是如果用户按下 Android 手机上的后退按钮,它会将他们带回到他们刚刚注销的页面,我不希望这样.如何更改
我有一个带有面板的表单,我可以在该面板上动态加载多个用户控件。我处理每个控件的事件。 UserControl userControl1 = LoadControl("control.ascx") as
我正在尝试为我们现有的 laravel 站点(laravel 5.2)的注销功能添加一些逻辑,但它不像登录那样简单。 客户端的现有注销工作正常,但我想要做的就是向我的 Cognito 实例添加一个调用
当前从注册处注销 M3 模型的首选方法是什么? 在我的项目中,我使用 Rascal 来分析大约 100 个大型 Java 程序,而我的 JVM 正在慢慢耗尽内存。我在旧版本的注册表中找到了 unreg
此主题与 Java 中的主题相关,但我找不到 C# 的解决方案。 http://theblasfrompas.blogspot.com/2010/01/closing-obsolete-databas
Slick 用大量的日志消息填满了控制台。我想,就像文档建议的那样,使用 slf4j-nop ,所以日志是关闭的,但是 Akka 需要自己的 slf4j 库。 所以我只剩下 akka-slf4j_2.
如果他空闲 20 分钟,我想提醒用户。所以,创建了一个服务。 它在桌面上运行良好,但在手机中它没有显示,有时如果屏幕在后台停留了几个小时,那么一旦我再次进入页面,注销对话框屏幕就会开始倒计时。 我的意
我是一名优秀的程序员,十分优秀!