How to use AppAuth-Android with IdentityServer4?
我已经为ASP.Net MVC客户端成功配置了Identityserver4,并且一切正常。
现在,我正在寻找开发一个Android应用程序客户端。 MVC客户端和Android客户端使用同一Identity Server进行身份验证和授权。
因此,对于Android客户端,我正在寻找" AppAuth-Android" GitHub库。但是我找不到任何示例或帮助在IdentityServer4中使用该库。我已经阅读了" AppAuth-Android"库的文档,并显示
In general, AppAuth can work with any Authorization Server (AS) that supports native apps.
所以我的问题是1)如何配置Identity Server以使其与Android应用程序一起使用。
2)如何在" AppAuth-Android"的帮助下对我的Android应用进行身份验证。
我们非常感谢您的帮助。
有人可以为" AppAuth-Android"创建标签吗?
服务器端的数据应与android应用中使用的数据相同。
将客户端添加到服务器端
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 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应用中,您应该具有相同的
我已经使用AppAuth-android库制作了一个示例,您应该在
轻松地,您可以对Identityserver4使用以下设置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 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 } |
无论如何,您可以参考https://github.com/IdentityServer/IdentityServer4/issues/479了解有关此问题的更多详细信息。