【问题标题】:Xamarin Forms Google Authenticateion, Error: disallowed_useragentXamarin 表单 Google 身份验证,错误:disallowed_useragent
【发布时间】:2018-01-26 18:43:53
【问题描述】:

目前我正在开发 Xamarin Forms 应用程序并添加了 Google 身份验证。 这是我的 PCL 代码:

var 验证器 = 新 OAuth2Authenticator( 客户标识, 空值, 常量.范围, 新的 Uri(Constants.AuthorizeUrl), 新的 Uri(redirectUri), 新的 Uri(Constants.AccessTokenUrl), 空值, 真的); 身份验证器.Completed += this.OnAuthCompleted; 验证器.Error += this.OnAuthError; AuthenticationState.Authenticator = 身份验证器; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(authenticator);

我正在使用最新版本的Xamarin.Auth,即1.5.0.3 这是我收到的:Screenshot

我浏览了许多文章和代码示例,但看起来谷歌可能再次更新了他们的身份验证。 Link 1Link 2Link 3Link 4。 Xamarin.Forms 示例官方页面上的事件无效且无法正常工作Link 5

我检查了几个代码示例,但同样没有成功,Sample 1 和多个示例here。我下载了源代码并尝试使用它,期望它可以工作,但它们也失败了。

您是否有针对此问题的解决方案或任何文章,这是最新的并且您知道它有效。代码示例也会很棒。

提前致谢!

【问题讨论】:

  • 看起来像是 Genymotion 模拟器,是否通过 Play 商店安装了 Chrome?
  • 我没有为 genymotion 安装任何额外的东西。 prntscr.com/g9ye5c prntscr.com/g9yei5 默认有google,但我可以试试不安装chrome。

标签: c# .net xamarin xamarin.forms google-authentication


【解决方案1】:

在 Android 上,出于安全原因,Google 要求现在使用 Chrome Custom Tabs 而不是 WebView

如果您运行的模拟器(或设备)没有安装 Chrome(从 OEM 或通过 Play 商店预安装),那么Xamarin.Auth 将默认使用WebView。这将在世界某些地区(即设备 OEM 可能未预装 Chrome 的中国)被 Google 接受,否则 Google 将通过 disallowed_useragent 错误拒绝 WebView 客户端。

如果您正在运行 GenyMotion 模拟器,请通过 Play 商店安装 Chrome。如果您没有安装 Play 商店,请安装 GApps(通过http://opengapps.org

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-16
    • 1970-01-01
    • 1970-01-01
    • 2020-08-03
    • 1970-01-01
    • 2014-06-07
    • 2017-01-04
    • 1970-01-01
    相关资源
    最近更新 更多