我正在尝试制作一个.net核心MVC客户端应用程序,使用oAuth2获取令牌以访问某些受保护的API。
授权URL需要以下URL参数:
除了“ unit_reference”之外,我知道如何设置它们中的大多数。这是一个自定义授权参数。
到目前为止,这是我在Startup.cs ConfigureServices中的代码:
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = "AccessProvider";
})
.AddCookie()
.AddOAuth("AccessProvider", options =>
{
options.ClientId = Configuration["AccessProvider:ClientId"];
options.ClientSecret = Configuration["AccessProvider:ClientSecret"];
options.CallbackPath = new PathString("/Account");
options.Scope.Add("acc");
// Missing unit_reference
options.AuthorizationEndpoint = "https://auth.test.com/Account/Login";
options.TokenEndpoint = "https://auth.test.com/Token";
options.SaveTokens = true;
});