我正在使用Microsoft Graph API生成oAuth 2.0访问令牌,该令牌将在1小时后过期。使用的路由是:[https://login.microsoftonline.com/[Tenant](https://login.microsoftonline.com/%5BTenant) ID]/oauth2/v2.0/token我在查询字符串中传递这些值。{ grant_type:"client_credentials",client_id:APP_ID
,client_secret:APP_PASSWORD
,scope:"https://graph.microsoft.com/.default",}
现在,我的当前实现添加了递归,在调用图形api从AD提取用户详细信息之前,我添加了重试。
有没有办法获取/获取刷新令牌,因为刷新令牌持续的时间更长?
发布于 2021-08-12 09:22:02
您需要按照以下步骤启用刷新令牌:
请求作用域'offline_access'.的
例如
POST /{tenant}/oauth2/v2.0/token
Host: https://login.microsoftonline.com
Content-Type: application/x-www-form-urlencoded
client_id=[client Id]
&scope=[scope]
&refresh_token=[refresh token]
&grant_type=refresh_token
&client_secret=[secret]
有关刷新令牌请求的详细信息,请参阅文档here。
发布于 2021-08-18 19:01:01
在我看来,使用刷新令牌和客户端流是没有用的。既然可以直接获取访问令牌,为什么还要添加一个额外的步骤来获取访问令牌呢?
使用client_credentials授权类型的流程:
步骤1:客户端身份验证
已颁发OK访问令牌
获取Refresh_token的流程
步骤1:客户端身份验证
第2步:刷新令牌验证并使用它来获取访问令牌
已颁发OK访问令牌。
https://stackoverflow.com/questions/68725344
复制相似问题