Dynamics 365 OAuth 不 return 刷新令牌
Dynamics 365 OAuth doesn't return refresh token
在授权用户访问他们的 Dynamics 365 环境时,我需要通过 OAuth 获得一个长期存在的刷新令牌。但是当我提出请求时,没有返回 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" 的 grant_type 将 "code" 交换为访问令牌。注意没有 refresh_token.
我已经像这样为 "app registration" 配置了 Azure 权限:
我真的想通了。 URL 需要格式化为版本 2 URL 并且版本 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")}
在授权用户访问他们的 Dynamics 365 环境时,我需要通过 OAuth 获得一个长期存在的刷新令牌。但是当我提出请求时,没有返回 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" 的 grant_type 将 "code" 交换为访问令牌。注意没有 refresh_token.
我已经像这样为 "app registration" 配置了 Azure 权限:
我真的想通了。 URL 需要格式化为版本 2 URL 并且版本 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")}