'flutter webview disallowed user agent
I am trying to openning sign-in google with webview in flutter application. I installed flutter_inappwebview: ^3.1.0 and this is my code:
child: InAppWebView(
initialUrl: url.toString(),
initialHeaders: {},
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
userAgent:
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
debuggingEnabled: true,
)),
but when i open google sin in page i got this error:
Solution 1:[1]
change userAgent to random like -> userAgent: "random". works perfectly! but then it will most likely low end mobile interface for google page. that's the only drawback. else works perfectly fine !
Solution 2:[2]
Using webview_flutter package you can fix the problem by adding userAgent: 'random', in the web view constructor. So, it will look like this:
WebView(
initialUrl: 'https://abdulrazakzakieh.com/',
userAgent: 'random',
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | princeoo7 |
| Solution 2 | Abdulrazak Zakieh |

