Dynamics 365 OAuth 不返回刷新令牌

3
我需要通过OAuth获得一个长期有效的刷新令牌,以授权用户访问其Dynamics 365环境。但是当我发出请求时,没有返回refresh_token值。
这是我用于OAuth请求的URL格式。
https://login.microsoftonline.com/common/oauth2/authorize?resource={Uri.EscapeDataString(options.field1)}&client_id={clientid}&response_type=code&redirect_uri={Uri.EscapeDataString(redirectUrl)}

它正确地调用了我的回调URL,然后我使用"authorization_code"授权类型交换了"code"以获取访问令牌。请注意,没有刷新令牌。

enter image description here

我已经为“应用程序注册”配置了以下Azure权限:

enter image description here

1个回答

4

其实我已经弄明白了。URL需要以版本2的格式进行格式化,版本2中没有“resource”参数,而是在“scopes”参数中传递资源。

https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize?client_id={clientid}&response_type=code&redirect_uri={Uri.EscapeDataString(redirectUrl)}&scope={Uri.EscapeDataString("offline_access https://xxx.crm.dynamics.com/user_impersonation")}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接