Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't access a httpOnly Cookies using the CookieManager #1995

Closed
2 tasks done
escamoteur opened this issue Jan 24, 2024 · 7 comments
Closed
2 tasks done

Can't access a httpOnly Cookies using the CookieManager #1995

escamoteur opened this issue Jan 24, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@escamoteur
Copy link

  • I have read the Getting Started section
  • I have already searched for the same problem

Environment

Technology Version
Flutter version 3.16.5
Plugin version 6.0.0
Android version 14
iOS version
macOS version
Xcode version
Google Chrome version

Device information: Pixel 7

Description

We have to handle Cloud Flare User Challenges that need to be shown in a WebView (in this case I used the WCInAppBrowser which works fine so far. unfortuantely the way the Cloudflare challenge works is that is stores a HttpOnly cookie on success which I need so that I can pass it with my API requests after the challenge suceeded.

I tried to list the existing cookies but the one from cloudflare that I can see in our webapp is not returned when I try:

            await browser.openData(
              data: response.body,
              settings: InAppBrowserClassSettings(
                webViewSettings: InAppWebViewSettings(
                  javaScriptEnabled: true,
                ),
              ),
              baseUrl: webUri,
            );
            await browser.exitCompleter.future;

            final cookies = await CookieManager.instance().getCookies(
                url: WebUri('https://mysite.com/'),
                webViewController: browser.webViewController);

Other cookies are sucessfully returned

Is there another way to intercept when the page creates the cookie?

@escamoteur escamoteur added the bug Something isn't working label Jan 24, 2024
Copy link

👋 @escamoteur

NOTE: This comment is auto-generated.

Are you sure you have already searched for the same problem?

Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!

If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.

In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE] or ios WKWebView [MY ERROR HERE] keywords.

Following these steps can save you, me, and other people a lot of time, thanks!

@escamoteur
Copy link
Author

Yep, I think I have tried almost everything and also did a lot of research

@pichillilorenzo
Copy link
Owner

Maybe the cookie is using another domain.
Open the WebView chrome inspector and check what domain is using the cookie you want to access.

@escamoteur
Copy link
Author

escamoteur commented Jan 24, 2024 via email

@pichillilorenzo
Copy link
Owner

As already written in the official website docs here: https://inappwebview.dev/docs/debugging-webviews#inspect-android-webviews:

On Android, in order to enable/disable debugging WebViews using chrome:https://inspect/#devices on Chrome, you should use the InAppWebViewController.setWebContentsDebuggingEnabled(bool debuggingEnabled) static method.

@escamoteur
Copy link
Author

escamoteur commented Jan 24, 2024 via email

@escamoteur
Copy link
Author

OK, it turned out that the inapp browser seems not to create cookies when using the browser.openData method. when use the openURLRequest method it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants