Important: Please read the Qt Code of Conduct -

Open login page of QOAuthAuthorizationCodeFlow with QWebEngineView

  • Hi together,

    i'm trying to solve following problem.


    I'm using the QOAuthAuthorizationCodeFlow to authenticate against a Service. For that a i have an instance oauth_ of the class QOAuthAuthorizationCodeFlow. Ok, then i'm setting all relevant attributes with member variables like:

    // and so on ...

    Then i'm configuring several connects with signals and slots which handle the requests and responses. Everything works fine.
    Now the relevant point. Up to now i used an external browser (firefox) to authenticate against the service. Here the code

    connect(oauth_, &QOAuthAuthorizationCodeFlow::authorizeWithBrowser, &QDesktopServices::opernUrl);

    The grant() function starts the OAuth 2 procedure.

    But i don't want to use the external browser. I have to use the QWebEngineView for authentication. I found this code snippet to open a page:

    QWebEngineView *view_ = new QWebEngineView;

    This also works.

    How can i connect the QWebEngineView with my QOAuthAuthorizationCodeFlow ?
    Anyone some ideas ?

    Thanks in advance

  • This is a great question and I'm dealing with the same issue, did you manage to figure out the solution? It would be great to share with the rest of us in case you managed to solve this issue...

    If not, this is what I'm going to try out tomorrow:

    1. The AuthorizeWithBrowser signal has a URL as parameter:
    2. I will create a public slot method where I create the web engine and open the page
    3. I will inject JavaScript code to automatically fill out the login form

    I will keep you posted!

Log in to reply