GetAuthCredentials not been invoked

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

GetAuthCredentials not been invoked

Postby chptx » Tue Feb 07, 2017 11:20 pm

platform: windows 7, VS2013
cef version: 2623 from cefbuilds.com

hello,

i have modify cefsimple project, add GetAuthCredentials method to SimpleHandler, which inherit from CefRequestHandler, then debug with:
cefsimple.exe --url=http://sample.com --proxy-server=https://myproxy.com –-remote-debugging-port=9999

and i use chrome devtool connect to localhost:9999, i can see that my proxy server has already response with header 'proxy-authenticate: Basic realm="SPDY Proxy"'
but GetAuthCredentials not been inovked at all, where breakpoint has been placed。

is anybody have the same problem as me?


Code: Select all
bool SimpleHandler::GetAuthCredentials(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, bool isProxy,
   const CefString& host, int port, const CefString& realm, const CefString& scheme, CefRefPtr<CefAuthCallback> callback)
{
   if (isProxy) {
      callback->Continue("abcdef", "123456");
      return true;
   }
   return false;
}
chptx
Newbie
 
Posts: 4
Joined: Tue Feb 07, 2017 10:38 pm

Re: GetAuthCredentials not been invoked

Postby magreenblatt » Wed Feb 08, 2017 10:48 am

Try using a supported version of CEF: https://bitbucket.org/chromiumembedded/ ... -supported
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: GetAuthCredentials not been invoked

Postby chptx » Wed Feb 08, 2017 10:34 pm

I tested same code on cef_binary_3.2924.1564.g0ba0378_macosx64 today, it has the same problem,with xcode debugging,process not hit the breakpoint at entry of SimpleHandler::GetAuthCredentials.

I have also tested my proxy server with chrome browser(macOS, 56.0.2924.87 64-bit), it works correctly.

Code: Select all
//simple_handler.h
class SimpleHandler : public CefClient,
                      public CefRequestHandler,
                      public CefDisplayHandler,
                      public CefLifeSpanHandler,
                      public CefLoadHandler {
public:
...
virtual bool GetAuthCredentials(
                                       CefRefPtr<CefBrowser> browser,
                                       CefRefPtr<CefFrame> frame,
                                       bool isProxy,
                                       const CefString& host,
                                       int port,
                                       const CefString& realm,
                                       const CefString& scheme,
                                       CefRefPtr<CefAuthCallback> callback) override;
...
}


//simple_handler.cc

bool SimpleHandler::GetAuthCredentials(
                                   CefRefPtr<CefBrowser> browser,
                                   CefRefPtr<CefFrame> frame,
                                   bool isProxy,
                                   const CefString& host,
                                   int port,
                                   const CefString& realm,
                                   const CefString& scheme,
                                   CefRefPtr<CefAuthCallback> callback) {
    if (isProxy) { // <= breakpoint here
        // Provide credentials for the proxy server connection.
        callback->Continue("myuser", "mypass");
        return true;
    }
    return false;
}

Last edited by chptx on Wed Feb 08, 2017 11:16 pm, edited 2 times in total.
chptx
Newbie
 
Posts: 4
Joined: Tue Feb 07, 2017 10:38 pm

Re: GetAuthCredentials not been invoked

Postby chptx » Wed Feb 08, 2017 10:44 pm

and I add parameter "--enable-logging --v=1", it output:

Code: Select all
[0209/112752.361103:VERBOSE1:http_stream_parser.cc(249)] SendRequest() request_line = "GET http://sample.com/ HTTP/1.1
" headers = "Host: sample.com
Proxy-Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8

"
[0209/112752.398351:VERBOSE1:http_stream_parser.cc(1054)] ParseResponseHeaders() content_length = "-1
" headers = "HTTP/1.1 407 Proxy Authentication Required
proxy-authenticate: Basic realm="SPDY Proxy"
"
[0209/112752.398896:VERBOSE1:resource_loader.cc(345)] OnResponseStarted: http://sample.com/
[0209/112752.399057:VERBOSE1:mime_sniffing_resource_handler.cc(351)] To buffer: http://sample.com/
[0209/112752.399556:VERBOSE1:resource_loader.cc(367)] OnReadCompleted: "http://sample.com/" bytes_read = 0
[0209/112752.400060:VERBOSE1:resource_loader.cc(655)] ResponseCompleted: http://sample.com/
chptx
Newbie
 
Posts: 4
Joined: Tue Feb 07, 2017 10:38 pm

Re: GetAuthCredentials not been invoked

Postby chptx » Thu Feb 09, 2017 2:43 am

problem is solved, through reading cef source code,I know that it should add these lines to simple_handler.h:

Code: Select all
  virtual CefRefPtr<CefRequestHandler> GetRequestHandler() OVERRIDE {
    return this;
  }
chptx
Newbie
 
Posts: 4
Joined: Tue Feb 07, 2017 10:38 pm

Re: GetAuthCredentials not been invoked

Postby diablosbg » Thu Jul 04, 2019 6:28 am

This solution works perfectly with cef_binary_3.3626.1894
diablosbg
Newbie
 
Posts: 2
Joined: Tue Jun 18, 2019 1:48 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 25 guests