大佬教程收集整理的这篇文章主要介绍了microsoft-graph – 为什么不返回刷新令牌的到期?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
对于授权类型“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
使用刷新令牌续订过期的访问令牌
“新的到期时间是expires_in和refresh_token_expires_in值中指定的秒数,分别来自成功提交令牌刷新请求的时间.”
“获取访问令牌”部分甚至指出:“在任何生产代码中,您的应用需要监视这些令牌的到期,并在刷新令牌到期之前续订过期的访问令牌.”但是,它似乎没有给我应该监控的到期时间.
在getHub上似乎有一个未解决的问题
https://github.com/OfficeDev/microsoft-graph-docs/issues/115
// 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实现,但说明了这个想法.
以上是大佬教程为你收集整理的microsoft-graph – 为什么不返回刷新令牌的到期?全部内容,希望文章能够帮你解决microsoft-graph – 为什么不返回刷新令牌的到期?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。