microsoft-graph – 为什么不返回刷新令牌的到期?
请求访问/刷新令牌时,会发送刷新令牌,但API响应中缺少“refresh_token_expires_in”属性.我不知道官方到期时间戳是什么.为什么缺少记录的财产?
对于授权类型“authorization_code”和“refresh_token”授权请求,我收到相同的响应正文.以下是我收到的一个例子. { "token_type": "Bearer","expires_in": "3599","scope": "Calendars.Read Calendars.ReadWrite Files.Read Files.ReadWrite User.Read User.Read.All","expires_on": "1455797016","not_before": "1455793116","resource": "https://graph.microsoft.com/","access_token": "eyJ0eXAiOiJKV1QiL...","refresh_token": "AAABAAAAiL9Kn2Z27Uub..." } 如您所见,仅包含访问令牌到期.一个额外的问题是这个“not_before”是什么?我找不到这个属性意味着什么的参考. http://graph.microsoft.io/en-us/docs/authorization/app_authorization “获取访问令牌”部分甚至指出:“在任何生产代码中,您的应用需要监视这些令牌的到期,并在刷新令牌到期之前续订过期的访问令牌.”但是,它似乎没有给我应该监控的到期时间. 在getHub上似乎有一个未解决的问题 解决方法
您可以在关闭或过期时检查过期使用刷新令牌来请求新的访问令牌:
// Get current time + 5 minutes (to allow for time differences) $now = time() + 300; if ($token->expires <= $now) { // Token is expired (or very close to it) so let's refresh // Initialize the OAuth client $oauthClient = new GenericProvider([ 'clientId' => config('msgraph.clientId'),'clientSecret' => config('msgraph.clientSecret'),'redirectUri' => config('msgraph.redirectUri'),'urlAuthorize' => config('msgraph.urlAuthorize'),'urlAccessToken' => config('msgraph.urlAccessToken'),'urlResourceOwnerDetails' => config('msgraph.urlResourceOwnerDetails'),'scopes' => config('msgraph.scopes') ]); $newToken = $oauthClient->getAccessToken('refresh_token',['refresh_token' => $token->refresh_token]); return $newToken->getToken(); } 这个例子来自Laravel实现,但说明了这个想法. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- windows-7 – 如何让Windows 7将与子网的VPN连接视为非“公
- .net – 如何在WPF中使用DrawThemeTextEx
- 在Windows上安装PHP PDO(xampp)
- 17 win7 sp1 x64/VS2015下配置creo4.0二次开发环境——调用
- windows – 具有最高CPU使用率的进程的名称
- Windows下串口编程
- 如何在D中导入COM dll
- [主板] [教程]在Windows 2012 R2上安装Intel I217-V/I218-V
- windows – 如何找出连接到互联网的NIC?
- Win2008 R2 64Bit下IIS环境安装memcache和memcached服务端的
- Azure访问控制服务(ACS) – ACS50001:未找到标识
- windows-server-2003 – 将Perfmon计数器名称放入
- windows – 如何在嵌入串行密钥的情况下安装Offi
- .net – 如何显示混合模式程序集的版本号是Windo
- 安装Windows Server 2008一次还是XP三次?
- Windows Server 2016-启用默认Windows搜索服务
- windows下安装PhpDocumentor(phpdoc)笔记
- .net – 是否有System.Windows.SystemColors的可
- windows – 如何通过windbg中的句柄获取文件路径
- 跟踪Microsoft SQL Server数据库中的更改