有人使用Xamarin.Auth或IdentityModel实现了IdentityServer4身份验证吗? 我已经尝试过使用IdentityModel和Xamarin.Auth,但它们的外观都缺少功能。
我似乎找不到在Xamarin.Auth的OAuth2Authenticator中设置response_type和response_mode的方法。 但是我喜欢如何打开本机浏览器并收听其完成/错误事件。对于未经授权的客户端,在这种情况下显然会出错,因为.Net Core中的IdentityServer4需要response_type和response_mode。
我似乎找不到使用IdentityModel与本机浏览器进行交互的方法,我已经读到推荐的方法是使用外部/本地浏览器而不是Webview。除此之外,使用Webview尝试通过google进行身份验证时,我收到disallowed_useragent错误。
答案 0 :(得分:0)
已解决。我最终使用Xamarin.Auth与IdentityServer4一起使用(至少在iOS中至少如此),因为Google身份验证(而非android)对将WebView与IdentityModel一起使用不满意。
对于可能与OAuth2Authenticator和IdentityServer4一起使用时遇到类似问题的其他开发人员的注释,以下是发生的事情和对我有用的事情:
由于我们在服务器中具有默认值,因此在IdentityServer4中不需要提供response_type和response_mode。
我的主要问题是Xamarin.Auth请求令牌时出现“ client_unauthorized”错误,因为RedirectUrl在末尾加了斜杠,而配置的RedirectUrl没有。
修复非常简单: 1.更改为我的客户端配置的RedirectUrl,使其末尾带有/(例如myappname:// oauth /) 2.在客户端中初始化RedirectUrl,以使OAuth2Authentic结尾于/(例如myappname:// oauth /)