Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 549
SteveP Avatar asked Apr 02 '15 13:04

SteveP


Video Answer


2 Answers

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';");
   }
}
like image 139
chris Avatar answered Sep 21 '22 15:09

chris


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

like image 20
amaitland Avatar answered Sep 25 '22 15:09

amaitland