Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

Connection refused on initial url #21

Closed
ghost opened this issue Jun 22, 2021 · 2 comments
Closed

Connection refused on initial url #21

ghost opened this issue Jun 22, 2021 · 2 comments

Comments

@ghost
Copy link

ghost commented Jun 22, 2021

hello,
I am building a web app with flutter and I need to have a user log in. I am doing this by hitting a authentication endpoint on an azure AD so I can get a code and subsequently get a token. here it what the initial URL looks like. line breaks added for readability. Also anything in <> is info that I would rather keep private.

https://login.microsoftonline.com/<tenant_id>/oauth2/v2.0/authorize?
client_id=<client_id>
&redirect_uri=$redirectUrl
&response_type=code
&response_mode=query
&scope=https://graph.microsoft.com/user.read
&code_challenge=<code_challenge>
&code_challenge_method=<code_challenge_method>

obviously this isn't of much help to anyone but i just wanted to give a sense of the structed or the URL. but if you would like to do you own test you can just use the link below which has the same result.
https://login.microsoftonline.com/

my webapp is hosted on firebase but also works on local host. however neither firebase or an azure ad are necessary to to reproduce the bug as you would just need a microsoft account and can use https://login.microsoftonline.com/ as the URL in WebViewX and make sure the flutter project has web.
Any clue as to how to get this working? any help would be greatly appreciated.

as for the set up of me WebViewx refer to code below

`@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("o365 login"),
actions: [
Padding(
padding: EdgeInsets.only(right: 20),
child: GestureDetector(
child: Icon(Icons.home),
onTap: () => _setUrl(), //I also has a method setup to set the same url as above to see if it was the initial URL causing the problem
),
)
],

  ),
  //Builder is wrapped around the webview to allow SnackBar to access the build context of the scaffold.
  // Without this the context would be from AuthLogin which does not contain a scaffold.
  body: Builder(builder: (context) =>
      WebViewX(
        key: ValueKey('webviewx'),
        initialContent: _initialUrl_noredirect,
        initialSourceType: SourceType.URL_BYPASS,
        onWebViewCreated: (controller) => webviewController = controller,
        onPageStarted: (url) => print('A new page has started loading...\n'),
        // onPageFinished: _getAuthCode,
        javascriptMode: JavascriptMode.unrestricted,
        webSpecificParams: WebSpecificParams(additionalSandboxOptions: ['allow-top-navigation', 'allow-top-navigation-by-user-activation', 'allow-downloads',
          'allow-popups',
          'allow-popups-to-escape-sandbox',
          'allow-presentation',
          'allow-same-origin',])
      )
  ),
);

}
`

@adrianflutur
Copy link
Owner

Hi, it's hard to tell what went wrong and/or if what you're trying to do (auth) is going to work through a proxy (because that's what this package uses - CORS-avoiding proxies, which AFAIK don't keep cookies when used).

Also please note that altough the web version of this package works for some use cases, it doesn't (and should NOT) be used for security-related things, like auth.

@adrianflutur
Copy link
Owner

Hi, please check this out #27
Here I explain the limitations of this package, and what are you trying to do seems like one of them.

Also, there's a new version available with multiple (breaking) changes available here: #26. Maybe you can use the new features to work-around your issue.
Closing this for now, please open a new issue if you encounter anything else.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant