Reputation: 1
Since a few days it seems that our Android and iOS apps are no longer able to connect using oAuth. Indeed we get a 403 "disallowed_useragent" error.
It seems that the use of a "Web application" Client ID is blocked from these applications. Yet on the Android version we are using a WebView.
After reading https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html :
Thank you in advance.
Cordially.
Upvotes: 0
Views: 142
Reputation: 2172
In Android:
Try the following code to fix the oAuth 2 Gmail connection failure issue in Android
mWebView.getSettings().setUserAgentString("Mozilla/5.0 Google");
In IOS:
Try the following code to fix the oAuth 2 Gmail connection failure issue in IOS
Objective C:
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36", @"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
Swift 3.0:
let dictionaty = NSDictionary(object: "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36", forKey: "UserAgent" as NSCopying)
UserDefaults.standard.register(defaults: dictionaty)
Or The another way is to add the below code in your config.xml file
<preference name="OverrideUserAgent" value"Mozilla/5.0 Google" />
For the brief information about that user agents refer the link: https://mobiforge.com/research-analysis/webviews-and-user-agent-strings
Upvotes: 1