SteveP
SteveP

Reputation: 19103

cefsharp app remember password option

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.

Upvotes: 7

Views: 7116

Answers (2)

chris
chris

Reputation: 106

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';");
   }
}

Upvotes: 4

amaitland
amaitland

Reputation: 4420

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).

Upvotes: 2

Related Questions