Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# net核心MVC OAuth,在授权URL中具有自定义属性_C#_Asp.net Core_Oauth 2.0_Asp.net Core Mvc - Fatal编程技术网

C# net核心MVC OAuth,在授权URL中具有自定义属性

C# net核心MVC OAuth,在授权URL中具有自定义属性,c#,asp.net-core,oauth-2.0,asp.net-core-mvc,C#,Asp.net Core,Oauth 2.0,Asp.net Core Mvc,我正在尝试创建一个.net核心MVC客户端应用程序,使用oAuth2获取一个令牌来访问一些受保护的API 授权URL需要以下URL参数: 范围 响应类型 重定向\u uri 客户识别码 单位参考 我知道如何设置它们中的大多数,除了“单位参考”。这是一个自定义授权参数 URL应如下所示: 这是我目前在Startup.cs ConfigureServices中的代码: services.AddAuthentication(options => { options.DefaultA

我正在尝试创建一个.net核心MVC客户端应用程序,使用oAuth2获取一个令牌来访问一些受保护的API

授权URL需要以下URL参数:

  • 范围
  • 响应类型
  • 重定向\u uri
  • 客户识别码
  • 单位参考
我知道如何设置它们中的大多数,除了“单位参考”。这是一个自定义授权参数

URL应如下所示:

这是我目前在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;
});

你得到答案了吗?我还想传递一些自定义参数。