luis901101 / oauth_webauth

BSD 3-Clause "New" or "Revised" License
15 stars 16 forks source link

Clear Cookies and Cache before launching. #10

Closed jijilpk closed 1 year ago

jijilpk commented 1 year ago

I have some session expiry issue due to cookie not cleared properly with my identity provider. I tried out with clear cache button. But it is not helping me. Is there any way we can force to clear existing cookies and cache before launching new in app web browser window, please let me know if this feature already exists. It will be useful to have a flag field for me to set in OAuthWebScreen() whether i can force clear cache and cookies.

luis901101 commented 1 year ago

If "Celar cache" button didn't work I'm afraid I can't help you. The clear cache button does a web view cache clear as stated in the in_app_webview_controller.dart

///Clears all the WebView's cache.
  ///
  ///**Supported Platforms/Implementations**:
  ///- Android native WebView
  ///- iOS
  Future<void> clearCache() async {
    Map<String, dynamic> args = <String, dynamic>{};
    await _channel.invokeMethod('clearCache', args);
  }

Try restarting your app after cache clear... it should not be necessary but just in case.

jijilpk commented 1 year ago

Clear cache will clear cookies aswell? When we launch OauthWebscreen ,will it works similar to incognitio window or will have previous session cookies?

luis901101 commented 1 year ago

Try with this:

import 'package:flutter_inappwebview/flutter_inappwebview.dart';

CookieManager cm = CookieManager.instance();
    cm.deleteAllCookies();

If that works for you then let me know and I can add some confs to allow cache and/or cookies clearing on start.

luis901101 commented 1 year ago

@jijilpk did this solve your problem?

Try with this:

import 'package:flutter_inappwebview/flutter_inappwebview.dart';

CookieManager cm = CookieManager.instance();
    cm.deleteAllCookies();

If that works for you then let me know and I can add some confs to allow cache and/or cookies clearing on start.

luis901101 commented 1 year ago

Anyway I just released v4.0.0+14, a breaking change which by the way has support for cookies clearing... so you can do a OAuthWebAuth.instance.clearCookies() or a full OAuthWebAuth.instance.clearAll() whenever you need.