【发布时间】:2019-08-07 00:02:58
【问题描述】:
我在 ADFS 2012R2 中实现了一个 OAuth2 提供程序,它在带有 NodeJS 服务器的 Xamarin 应用程序中都被使用。我想针对我的 NodeJS Rest Endpoints 编写自动化测试,因此我需要从 ADFS 以编程方式生成 access_token。我进行了广泛搜索,似乎无法弄清楚如何以编程方式从 ADFS 3.0 获取 access_token(2016 及更高版本有更多支持的授权类型允许它)。有谁知道如何做到这一点?
我在这里尝试过这个解决方案:Does ADFS 2012 R2 support Auth2 Resource Owner Password Credentials flow,端点为“https://myadfsserver/adfs/oauth2/token” grant_type=password,但这不起作用,因为 ADFS 2012R2 不支持该 grant_type。
我已经尝试过 ADAL:
AuthenticationContext ac = new AuthenticationContext(AuthorizeUrl, false);
AuthenticationResult result;
try
{
result = await ac.AcquireTokenAsync(Resource, ClientId, new UserPasswordCredential("username", "password"));
}
但一次失败,出现 3 个不同的异常。
任何帮助都会很棒。
【问题讨论】: