Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.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
如何将AppAuth Android与IdentityServer 4一起使用?_Android_Identityserver4 - Fatal编程技术网

如何将AppAuth Android与IdentityServer 4一起使用?

如何将AppAuth Android与IdentityServer 4一起使用?,android,identityserver4,Android,Identityserver4,我已经成功地为我的ASP.NETMVC客户端配置了Identityserver4,一切正常。 现在我想开发一个Android应用程序客户端。MVC客户端和Android客户端使用相同的身份服务器进行身份验证和授权。 所以对于Android客户端,我正在寻找GitHub库。但是我找不到任何使用IdentityServer4库的示例或帮助。我已经阅读了“AppAuth Android”库的文档,它说 通常,AppAuth可以与支持本机应用程序的任何授权服务器(AS)配合使用 因此,我的问题是1)如何

我已经成功地为我的ASP.NETMVC客户端配置了Identityserver4,一切正常。 现在我想开发一个Android应用程序客户端。MVC客户端和Android客户端使用相同的身份服务器进行身份验证和授权。 所以对于Android客户端,我正在寻找GitHub库。但是我找不到任何使用IdentityServer4库的示例或帮助。我已经阅读了“AppAuth Android”库的文档,它说

通常,AppAuth可以与支持本机应用程序的任何授权服务器(AS)配合使用

因此,我的问题是1)如何配置我的Identity Server以使用Android应用程序。
2) 如何借助“AppAuth Android”验证我的Android应用程序

非常感谢您的帮助


有人能为“AppAuth Android”创建一个标签吗?

基本上,您可以对IdentityServer 4使用以下设置

new Client
           {
               ClientId = "client.android",
               RequireClientSecret = false,
               ClientName = "Android app client",
               AllowedGrantTypes = GrantTypes.Code,
               RequirePkce = true,
               RequireConsent = false,

               RedirectUris = { "net.openid.appauthdemo://oauth2redirect" },
               AllowedScopes =
               {
                   IdentityServerConstants.StandardScopes.OpenId,
                   IdentityServerConstants.StandardScopes.Profile,
                   IdentityServerConstants.StandardScopes.Email,
                   IdentityServerConstants.StandardScopes.Phone,
                   "api1"
               },
               AllowOfflineAccess = true
           }

无论如何,有关此问题的详细信息,您可以参考。

服务器端的数据应与android应用程序中使用的数据相同

将客户端添加到服务器端

  new Client
        {
            ClientId = "myClientId",
            ClientName = "myClientName",
            AllowedGrantTypes = GrantTypes.CodeAndClientCredentials,
            RequireConsent = false,

            ClientSecrets =
            {
                new Secret("myClientSecret".Sha256())
            },

            RedirectUris = { "myRedirectUri://callback" },

            AllowedScopes =
            {
                IdentityServerConstants.StandardScopes.OpenId,
                IdentityServerConstants.StandardScopes.Profile,
                IdentityServerConstants.StandardScopes.Email,
                IdentityServerConstants.StandardScopes.Phone,
            },

            AllowOfflineAccess = true
        }
在android应用程序中,您应该具有相同的
clientId
clientSecret
重定向URI


我使用AppAuth android库制作了一个示例,您只需编辑
gradle.properties
中的数据,从IdentityServer的角度检查它,为混合授权类型和所需的PKCE配置客户端。然后打开日志记录,查看客户端连接时发生的情况。如果发现AppAuth和IdentityServer4之间不兼容-请在IS4问题跟踪器上打开问题。确定!我会尝试一下,并告诉你最新情况。感谢如果将客户端配置为混合授权类型和必需的PKCE,我将在日志中收到错误“客户端的授权类型无效:授权代码”。如果我将授权类型更改为“GrantTypes.code”,则一切正常。我在AppAuth中找不到任何更改授权类型的选项。有什么想法吗?请编辑您的答案,包括详细信息和解决方案,而不仅仅是link@I我知道这有点旧了,但我想知道您是否可以告诉我redirecdt URI应该是什么样子?是com.mysite.myapp还是其他什么?