Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

JWT authenication in qml



  • Hi,
    I am very much new to REST API, I tried Flickr Calls example that 's was given in book Qt5 Cadaques.
    I faced two problems,

    1. I could assign json object to listView model but this did not work
      for example:
    In javascript function I am writing as
    if(xhr.readyState === XMLHttpRequest.DONE)
          json = JSON.parse(xhr.responseText.toString())
          for(var i=0; i<json.length; i++) {
              view.model = json[i].id
          }
    }
    
    In ListView's Delegate:
    delegate: Image {                      
                 source: "/home/images/test_" + modelData.id + ".png
    }
    
    1. I have user name : "admin" and password: "123" receiving from end points
      I have created two textInput for user to enter his user name and password
      and writing javascript function called request
    function request() {
            var xhr = new XMLHttpRequest();
            if(xhr.readyState === XMLHttpRequest.DONE) {
               var json = JSON.parse(xhr.responseText.toString())
    }
           xhr.open("POST", url, true, "admin", "123") 
           xhr.send("userName=user&password=pwd");  /*sending entered text from textInput to http*/
    }
    

    This does not get authenticated and moves to next screen. What and where am I doing wrong.

    Thanks in advance for the support and quick response


Log in to reply