问题
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