1

As part of my C++ app, I'm needing to log into a web service which has an oauth2 login flow. I'm wanting to use webkitgtk-3.0 to accomplish this however, I'm having trouble detecting the login is complete.

What I need to do is detect when the browser wants to redirect to "http://localhost:12345" before it actually attempts to do so.

I've tried looking at the answers from here: Webkit GTK :: How to detect when a download has finished?

But none of them work. Unfortunately the final page loaded, is what is able to be loaded, not http://localhost:12345. Since there is nothing listening on http localhost port 12345. i.e. from my load_finished_cb:

static void load_finished_cb(WebKitWebView *web_view, WebKitWebFrame *web_frame, gpointer data) 
{
      printf("Finished downloading %s\n", webkit_web_view_get_uri(web_view));
}

The value printed above is in fact a url to my login service and not localhost:12345 as I'd hoped.

What I'm really after is a callback to pre-browse. How do I detect that? Is it even possible? I know it is with webkit2, but I don't want to use webkit2. I wan't to use webkit and there is a very good reason for that that I won't get into here.

FYI: Under webkit2 what I would do is:

g_signal_connect(web_view, "load-changed", ... );

And in the callback for load-changed detect WEBKIT_LOAD_STARTED and check the value for the URI.

Community
  • 1
  • 1
hookenz
  • 36,432
  • 45
  • 177
  • 286
  • Looks like load-error-callback is the best option. After lots of testing, it's the only one that detected the redirect. – hookenz Mar 18 '16 at 02:43

0 Answers0