撤销PHP中的Google Access令牌 [英] Revoke Google Access Token in PHP

查看:103
本文介绍了撤销PHP中的Google Access令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当标题读取时,我想以编程方式撤消授权的访问令牌(在PHP中是这样)。我在他们的网站上发现了这一点,但似乎找不到功能在 API客户端库中。是否有一个干净的库函数?



编辑:
正如 DaimTo 有一个名为revokeToken()的函数。所以这段代码可以在PHP中使用(使用composer):

  require_oncevendor / autoload.php; 
$ client = new Google_Client();
$ client-> setApplicationName(GOOGLE_APP_NAME);
$ client-> setClientId(GOOGLE_CLIENT_ID);
$ client-> setClientSecret(GOOGLE_CLIENT_SECRET);
$ client-> revokeToken($ access_token);


解决方案

try

  $ client-> revokeToken(); 

  $客户端 - > revokeToken($的accessToken); 

通过挖掘 Google-api-php-Client

As the title reads, I want to revoke a granted access token programatically (in PHP that is). I found this on their website, but can't seem to find a function in the api client library. Is there a clean library function?

EDIT: As pointed out by DaimTo there is a function called revokeToken(). So this code works in PHP (with composer):

require_once "vendor/autoload.php";
$client = new Google_Client();
$client->setApplicationName(GOOGLE_APP_NAME);
$client->setClientId(GOOGLE_CLIENT_ID);
$client->setClientSecret(GOOGLE_CLIENT_SECRET);
$client->revokeToken($access_token);

解决方案

try

$client->revokeToken(); 

or

$client->revokeToken($accesstoken);

Information found by digging around the Google-api-php-Client

这篇关于撤销PHP中的Google Access令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆