首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Xamarin.Auth或IdentityModel + IdentityServer4

Xamarin.Auth或IdentityModel + IdentityServer4
EN

Stack Overflow用户
提问于 2019-03-05 11:00:34
回答 1查看 457关注 0票数 0

是否有人使用Xamarin.Auth或IdentityModel实现了Xamarin.Auth身份验证?我试过使用IdentityModel和Xamarin.Auth,从外观上看,它们都有缺失的特性。

  1. 我似乎找不到在Xamarin.Auth中设置response_type和response_mode的方法。但我喜欢打开本机浏览器并侦听其完成/错误事件的方式。在这种情况下,这显然是对未经授权的客户端的错误,因为我们在.Net Core中的.Net需要response_type和response_mode。
  2. 我似乎找不到一种方法来与本机浏览器交互,我看过推荐的方法是使用外部/本机浏览器而不是webview。此外,在使用webview试图与google进行身份验证时,我会得到disallowed_useragent错误。
EN

回答 1

Stack Overflow用户

发布于 2019-03-07 00:01:31

解决了。最后,我使用了Xamarin.Auth与IdentityServer4 (至少目前在iOS中)合作,因为Google (而不是android)不喜欢在IdentityModel中使用WebView。

对于其他可能在OAuth2Authenticator中使用IdentityServer4时遇到类似问题的开发人员,下面是发生了什么以及对我起了什么作用:

  1. 事实证明,response_type和response_mode在我们的IdentityServer4中并不是必需的,因为服务器中有缺省值。
  2. 我的主要问题是,当client_unauthorized请求令牌时,我得到了一个“Xamarin.Auth”错误,因为RedirectUrl在末尾有一个斜线,而配置的RedirectUrl没有。
代码语言:javascript
复制
- My RedirectUrl didn't have a slash at the end when initialising OAuth2Authenticator
- The extra slash at the end was magically added when I converted NSUrl to Uri inside the OpenUrl method in AppDelegate.cs before calling OneListAppContext.AuthenticationState.Authenticator.OnPageLoading(url). 
- I guess it's a standard to have a slash before the question mark in the url query? If it is, I didn't know that because adding ?name=value in the url has always worked.  
- NSUrl coming from Safari in the OpenUrl method was myappname://oauth?code=1ec450f88737fcae0a2786699d5df24e3ca97a8b55c09da2ef13d58035821134...
- New Uri after converting NSUrl to Uri was was myappname://oauth/?code=1ec450f88737fcae0a2786699d5df24e3ca97a8b55c09da2ef13d58035821134... (notice there's / after oauth)

修复非常简单: 1.将我的客户端配置的RedirectUrl更改为有/在末尾(例如myappname://oauth/) 2.将RedirectUrl在客户机中初始化为OAuth2Authentic /在末尾(例如myappname://oauth/)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55001288

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档