I'm building a web browser an recently I came across an error while trying to login using my Google account on a website.
This is strange because I checked the user agent of my app and Safari's and they are both identical.
Any suggestions?
UPDATE
The WKWebView is nested 3 levels deep inside a tree of custom UIViews.
Here's the initialization code:
_webView = [[WKWebView alloc] init];
_webView.allowsBackForwardNavigationGestures = NO;
_webView.allowsLinkPreview = NO;
_webView.navigationDelegate = self;
_webView.UIDelegate = self;
_webView.frame = CGRectMake(0.0, 0.0, self.contentView.frame.size.width, self.contentView.frame.size.height);
[self.contentView addSubview:_webView];
Please go to the Google Play Store, download Chrome (it must be Chrome), set Chrome as the default browser, and attempt to add the account again. This will allow you to proceed without issue. If you have further questions, we are available to help at Settings > Help & Feedback > Contact Support.
From Google Modernizing OAuth interactions in Native Apps for Better Usability and Security article:
On April 20, 2017, we will start blocking OAuth requests using web-views for all OAuth clients on platforms where viable alternatives exist.
So, Google now allows sign-in with Google Account only in normal browsers, it restricts it in web-views due to security reasons and recommends Google SDKs for iOS and Android for this purpose.
But if you still want to use WKWebView
you may do a little trick, suggested in this answer, setting customUserAgent
so it can pass validation:
// Check for selector availability, as it is available only on iOS 9+
if ([_webView respondsToSelector:@selector(setCustomUserAgent:)]) {
_webView.customUserAgent = @"MyCustomUserAgent";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With