HTTP request POST in QT application QT 5.3.2



  • Hi,
    I want to send the following oauth HTTP POST request using qt netwok apis.

    url: https://accounts.google.com/o/oauth2/token

    POST /accounts/o8/oauth2/token HTTP/1.1
    Host: www.google.com
    Content-Type: application/x-www-form-urlencoded

    client_id=21302922996.apps.googleusercontent.com&
    client_secret=XTHhXh1SlUNgvyWGwDk1EjXB&
    code=4/P7q7W91a-oMsCeLvIaQm6bTrgtp6&
    redirect_uri=urn:ietf:wgauth:2.0ob&
    grant_type=authorization_code

    Can anybody help me out how to use qt api classes QNetworkRequest,QNetworkAccessManager,QNetworkRepl y for the above HTTP POST request.
    I an using raspberry pi 3 QT creator 3.2.1 based on QT 5.3.2.

    Thanks


  • Moderators

    You do realise you have posted your oauth secret here publicly?

    Are you forced to use such an old Qt version? If no, then please consider upgrading to Qt 5.8 or 5.9, where you can use the convenience QtNetworkAuth module.

    If yes, then you have already discovered all relevant classes needed in this case. Read the docs, all info on how to build requests is there. If something is unclear, feel free to ask here, of course.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.