Xamarin Forms app throwing disallowed_useragent error with Google Authentication

情到浓时终转凉″ 提交于 2019-12-12 02:43:38

问题


I am developing Xamarin Forms PCL app in which I am trying to integrate Google Authentication with Xamarin.Auth component. But unfortunately I am getting disallowed_useragent error while trying to authenticate with Google. Everything is working fine with Facebook and other Social Media authentication.

Any help would great for me to go ahead.


回答1:


The problem happens because google has recently changed it policy to not allow WebViews (and other embedded browsers) to be a part of the authorization process. One should instead use the new, native browsers: CustomTabs on Android and a Safari thing (Sorry, i forgot the name) on iOS.

To solve the issue:
1. Update Xamarin.Auth to the newest version
2. Install the Xamarin.Support.CustomTabs NuGet package (I think it installs itself with the newest Auth version)
3. In the Authenticator constructor add a true value for the IsUsingNativeUI property
4. Call the GetUI() function and cast it's value to CustomTabsIntent.Builder
5. Call builder.Build().LaunchUrl() with the Authenticator.GetInitialUrlAsync() function


Hope it helps!




回答2:


disallowed_useragent means (most likely) app is using embedded WebViews which are forbidden since 2017-04-20.

Xamarin.Auth supports CustomTabs and SafariView controller since 2017-03-2x nuget version v.1.4.x. Version 1.5.0 has Forms support integrated.



来源:https://stackoverflow.com/questions/43517508/xamarin-forms-app-throwing-disallowed-useragent-error-with-google-authentication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!