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
如何使用ASP.NET Core 3.1将Android应用程序集成到Identity Server进行身份验证?_Android_Asp.net Core_Authentication_Identityserver4_Access Token - Fatal编程技术网

如何使用ASP.NET Core 3.1将Android应用程序集成到Identity Server进行身份验证?

如何使用ASP.NET Core 3.1将Android应用程序集成到Identity Server进行身份验证?,android,asp.net-core,authentication,identityserver4,access-token,Android,Asp.net Core,Authentication,Identityserver4,Access Token,我已经用Angular模板创建了ASP.NET核心项目,并使用visual studio进行了身份验证。现在我正在开发Android应用程序,并希望将其与我现有的ASP.NET CORE 3.1 WEB API(后端)集成。 我在appsettings.json中为我的android应用程序添加了客户端,如下所示: "IdentityServer": { "Clients": { "MyAngularApp": {

我已经用Angular模板创建了ASP.NET核心项目,并使用visual studio进行了身份验证。现在我正在开发Android应用程序,并希望将其与我现有的ASP.NET CORE 3.1 WEB API(后端)集成。 我在appsettings.json中为我的android应用程序添加了客户端,如下所示:

"IdentityServer": {
    "Clients": {
       "MyAngularApp": {
           "Profile": "IdentityServerSPA"
       },
       "MyMobileApp": {
           "Profile": "NativeApp"
       }
    }
}
当我调用我的配置端点时“https://localhost:4042/_configuration/MyMobileApp“,我得到了以下回应

{"authority":"https://localhost:4042","client_id":"MyMobileApp","redirect_uri":"urn:ietf:wg:oauth:2.0:oob","post_logout_redirect_uri":"urn:ietf:wg:oauth:2.0:oob","response_type":"code","scope":"offline_access MyAppAPI openid profile"}
我有以下问题,

  • 在重定向uri中,“urn:ietf:wg:oauth:2.0:oob”是什么意思

  • 当我在客户端设置中添加重定向uri时

    “MyMobileApp”:{“Profile”:“NativeApp”,“RedirectUri”:“com.example.myapplication”}

    但是我在调用端点时没有得到定义的重定向uri "https://localhost:4042/_configuration/MyMobileApp”作为回应,我得到了这个 “重定向uri”:“urn:ietf:wg:oauth:2.0:oob”。那么,如何更改默认重定向URI


我正在使用Android中的AppAuth库与Identity Server集成。

在appsetting.json中尝试您必须使用Identity Server-客户端尝试这可能会解决您的问题

"IdentityServer": {
  "IssuerUri": "urn:sso.company.com",
  "Clients": [
    {
      "Enabled": true,
      "ClientId": "local-dev",
      "ClientName": "Local Development",
      "ClientSecrets": [ { "Value": "<Insert Sha256 hash of the secret encoded as Base64 string>" } ],
      "AllowedGrantTypes": [ "implicit" ],
      "AllowedScopes": [ "openid", "profile" ],
      "RedirectUris": [ "https://localhost:5001/signin-oidc" ],
      "RequireConsent": false
    }
  ]
}

“IdentityServer”:{
“IssuerUri”:“urn:sso.company.com”,
“客户”:[
{
“启用”:正确,
“客户端ID”:“本地开发人员”,
“客户名称”:“本地开发”,
“ClientSecrets”:[{“值”:“}],
“AllowedGrantTypes”:[“隐式”],
“AllowedScopes”:[“openid”,“配置文件”],
“重定向URI”:[“https://localhost:5001/signin-oidc“],
“RequireSend”:错误
}
]
}

在appsetting.json中尝试您必须识别服务器-客户端尝试这可能是您的问题将得到解决的原因

"IdentityServer": {
  "IssuerUri": "urn:sso.company.com",
  "Clients": [
    {
      "Enabled": true,
      "ClientId": "local-dev",
      "ClientName": "Local Development",
      "ClientSecrets": [ { "Value": "<Insert Sha256 hash of the secret encoded as Base64 string>" } ],
      "AllowedGrantTypes": [ "implicit" ],
      "AllowedScopes": [ "openid", "profile" ],
      "RedirectUris": [ "https://localhost:5001/signin-oidc" ],
      "RequireConsent": false
    }
  ]
}

“IdentityServer”:{
“IssuerUri”:“urn:sso.company.com”,
“客户”:[
{
“启用”:正确,
“客户端ID”:“本地开发人员”,
“客户名称”:“本地开发”,
“ClientSecrets”:[{“值”:“}],
“AllowedGrantTypes”:[“隐式”],
“AllowedScopes”:[“openid”,“配置文件”],
“重定向URI”:[“https://localhost:5001/signin-oidc“],
“RequireSend”:错误
}
]
}

使用此客户端配置时,我遇到编译时错误“System.InvalidOperationException:'类型“”不受支持”。此异常最初是在此调用堆栈中引发的:Microsoft.AspNetCore.ApiAuthorization.IdentityServer.ConfigureClients.GetClients()Microsoft.AspNetCore.ApiAuthorization.IdentityServer.ConfigureClients.Configure(Microsoft.AspNetCore.ApiAuthorization.IdentityServer.ApiAuthorizationOptions)Microsoft.Extensions.Options.OptionFactory.Create(string).“。使用此客户端配置时,出现编译时错误“System.InvalidOperationException:'不支持类型“”。此异常最初是在此调用堆栈中引发的:Microsoft.AspNetCore.ApiAuthorization.IdentityServer.ConfigureClients.GetClients()Microsoft.AspNetCore.ApiAuthorization.IdentityServer.ConfigureClients.Configure。”(Microsoft.AspNetCore.ApiAuthorization.IdentityServer.ApiAuthorizationOptions)Microsoft.Extensions.Options.Options工厂创建(字符串)…”。