cefsharp app remember password option
Asked Answered
D

2

7

I am embedding a webapp using CefSharp which is all working fine. However, when logging into the app, CEF doesn't offer to remember the username and password like it does when opening the app in normal Chrome.

Is there a way in CefSharp to get cef to ask to remember usernames/password so that when uses go back to the app, they will be able to sign in quicker ?

I have tried using some command line args e.g.

CefSettings cs = new CefSettings();
cs.CefCommandLineArgs.Add("enable-automatic-password-saving", "enable-automatic-password-saving");
cs.CefCommandLineArgs.Add("enable-password-save-in-page-navigation", "enable-password-save-in-page-navigation");
Cef.Initialize(cs);

but so far, cef has not prompted me to save the username/password.

Dearr answered 2/4, 2015 at 13:55 Comment(0)
U
4

I had the same issue and resolved it by injecting some javascript from the FrameLoadEnd event. Something like:

void wb_FrameLoadEnd(object sender, FrameLoadEndEventArgs e)
{
  if (e.Url.Equals(@"https://yyy.zzz.com/"))
  {
    var wb = sender as ChromiumWebBrowser;
    wb.EvaluateScriptAsync
        (@"document.querySelector('input#username').value='steve';");
   }
}
Understudy answered 8/4, 2015 at 13:40 Comment(2)
That's a good idea if I wanted to default the username etc. However, I want the browser to remember the password as different users will be using the app, and I don't always have control of the HTML displayed (it can come from third-party websites).Dearr
You could make this code more generic by adding javascript code that triggers when forms are submitted and loaded and offers to save to local storage or something. It might also be possible to use one of the extensions already doing this like LastPass.Arkwright
O
2

CefSharp doesn't support remember password prompt. I don't believe that CEF does either, though it's probably worth asking on http://magpcss.org/ceforum/ for a definitive answer (There's no reference in the API for the current version).

I'll also point of that unless explicitly told CEF will use an in memory cookie store, so session cookies won't be persisted. You need to specify CefSettings.CachePath to persist cookies (and other cache able data).

Overdraft answered 2/4, 2015 at 22:58 Comment(3)
Thanks for the answer. I found the CachePath setting for the cookies, but I was hoping that the commandLineArgs would have some options to allow the remember password functionality.Dearr
CEF is no frills when it comes to that sort of thing, there's no download manager either. My guess is that some of these features aren't part of the core Chromium open source project. If you haven't already it's probably still worth asking on the ceforum, see if anyone there has any pointers.Overdraft
No plans for CEF support see magpcss.org/ceforum/viewtopic.php?f=7&t=17293 for official response.Overdraft

© 2022 - 2024 — McMap. All rights reserved.