Nominate our 2022 Qt Champions!

JWT authentication in WebEngineView

  • Hello,

    I am working on a project where I want to embed elements from a website in a QML application inside the WebEngineView-object.
    Our webapp uses JSONWebTokens for authentication, which is stored in the browser / localStorage along with the userId.

    We already use the API in our webapp for sending / recieving data using JSON to our cloud services, and to access the API we log in using a XmlHtttpRequest. This request returns userId and token, which in turn is stored in the QML application.

    Is there a way to pass this userId and token (two strings) from the QML application to localStorage in the WebEngineView so that you don't need to login both places? Or is there any other way to log in to a website inside a WebEngineView-object from a QML application? I was thinking about using the runJavaScript-function in WebEngineView, but have not found a solution yet.

Log in to reply