Search code examples
pythonseleniumproxy-authenticationcefpython

CEF Python Proxy Authentication


Is there a way to add Proxy Authentication in CEF Python?

The best answer I could find is here. The problem is that the code is written in C# and I couldn't manage to convert it to Python.


Solution

  • CEF Python currently does not support all the features of the referenced C# example.

    You can set proxy using command line switches with the "proxy-server" switch, but this can be set only once during initialization when calling cef.Initialize. Chromium preferences (the SetPreference method in C#) which allow for setting options during runtime are not supported yet, this is to be implemented via Issue #244. This isue is marked "next-release2", so this should be implemented in one of next releases (a few months usually).

    CEF Python supports RequestHandler.GetAuthCredentials callback. If you need GUI dialog for entering username/password then you need to implement this in your app using GTK/Qt or whatever GUI framework you use. There is no default implementation of auth credentials dialog in upstream CEF, applications need to implement such control on their own. On a side note there was a default implementation for auth dialogs on Windows in CEF Python 1 - but that's a very old version, code is available here.