gpt4 book ai didi

c# - Xamarin 表单 Google 身份验证,错误 : disallowed_useragent

转载 作者:行者123 更新时间:2023-11-30 16:43:02 24 4
gpt4 key购买 nike

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

var authenticator = new OAuth2Authenticator(    clientId,    null,    Constants.Scope,    new Uri(Constants.AuthorizeUrl),    new Uri(redirectUri),    new Uri(Constants.AccessTokenUrl),    null,    true);authenticator.Completed += this.OnAuthCompleted;authenticator.Error += this.OnAuthError;AuthenticationState.Authenticator = authenticator;var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();presenter.Login(authenticator);

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

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

我检查了几个代码示例,但还是没有成功,Sample 1和多个样本 here .我下载源代码并尝试使用它,希望它能正常工作,但它们也失败了。

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

提前致谢!

最佳答案

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

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

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

关于c# - Xamarin 表单 Google 身份验证,错误 : disallowed_useragent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45750554/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com