2

I have a Flutter app that's leveraging a Webview. The location of this Webview is an external site that supports Google auth, which is failing due to a 403 disalowed_useragent. I know that Google no longer supports OAuth requests using embedded browsers, but does anyone know of a workaround?

class CheckOutExternalPage extends StatefulWidget {
  final String url;

  CheckOutExternalPage({Key key, this.url}) : super(key: key);

  @override
  _CheckOutExternalPageState createState() => _CheckOutExternalPageState();
}

class _CheckOutExternalPageState extends State<CheckOutExternalPage> {
  @override
  Widget build(BuildContext context) {
    return WebviewScaffold(
      geolocationEnabled: true,
      withZoom: true,
      withLocalStorage: true,
      withJavascript: true,
      supportMultipleWindows: true,
      url: widget.url,
      appBar: new AppBar(
        title: const Text('Check Out'),
      ),
    );
  }
}

1 Answer 1

3

Read Api at https://pub.dev/documentation/webview_flutter/latest/webview_flutter/WebView/userAgent.html

so you have to use something like

String useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36";

and then webview.userAgent=useragent ;

Sign up to request clarification or add additional context in comments.

1 Comment

Now I get this error: Scripts may close only the windows that were opened by it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.