i can't find what wrong in my code. Im try test use this data at https://www.hurl.it and it return json.
But when run Qt, i got error

Qt Code:
  1. 1: "4/ufy-e-ud4_3XxlHYN7VNp0nZB9G26EzLX_CrEt0F3QA"
  2. ***** request url= QUrl("www.googleapis.com/oauth2/v4/token")
  3. ***** request content type header= 0
  4. ***** call POST *****
  5. qt.network.ssl: QSslSocket: cannot resolve SSLv2_client_method
  6. qt.network.ssl: QSslSocket: cannot resolve SSLv2_server_method
  7. 5
  8. ***** finishedSlot! *****
  9. ***** reply http error = 301
  10. ***** response ***** ""
To copy to clipboard, switch view to plain text mode 

PLZ ANYONE CAN HELP ?

Qt Code:
  1. #include "gettoken.h"
  2. #include <QNetworkRequest>
  3. #include <QFile>
  4. #include <QDir>
  5. #include <QTextCodec>
  6. #include <QUrlQuery>
  7. #include <QUrl>
  8. #include <QSslSocket>
  9.  
  10. getToken::getToken(QObject *parent) : QObject(parent)
  11. {
  12. appID = "1037983989117-p3cllh8ou68c32v9irrh7i9fcdk8egs7.apps.googleusercontent.com";
  13. secretString = "uQQZK2Jb9XOprgYzYjrrWj3s";
  14. qReply = Q_NULLPTR;
  15. accessUrl = "www.googleapis.com/oauth2/v4/token";
  16. qnam = new QNetworkAccessManager(this);
  17. }
  18.  
  19. void getToken::requestToken(QString code)
  20. {
  21.  
  22. qDebug()<<"1: "<<code; //very sure this is right code
  23. QUrl setUrl(accessUrl);
  24. QNetworkRequest qRequest(setUrl);
  25. qRequest.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
  26. connect(qnam,SIGNAL(finished(QNetworkReply *)), this,SLOT(writeFile(QNetworkReply *)));
  27.  
  28.  
  29. QByteArray qByte;
  30. qByte.append("code="+code+"&");//very sure this is right code
  31. qByte.append("client_id=1037983989117-p3cllh8ou68c32v9irrh7i9fcdk8egs7.apps.googleusercontent.com&");
  32. qByte.append("client_secret=uQQZK2Jb9XOprgYzYjrrWj3s&");
  33. qByte.append("redirect_uri=http://localhost:8080/cb&");
  34. qByte.append("grant_type=authorization_code");
  35.  
  36. qDebug() << "***** request url=" << qRequest.url();
  37. qDebug() << "***** request content type header=" << qRequest.ContentTypeHeader;
  38. qDebug() << "***** call POST *****";
  39. qnam->post(qRequest, qByte);
  40. // qnam.post(qRequest,qByte);
  41.  
  42. qDebug()<<"5";
  43.  
  44. // qDebug()<<"almost done";
  45. }
  46.  
  47. void getToken::writeFile(QNetworkReply *mReply)
  48. {
  49. qDebug() << "***** finishedSlot! *****";
  50. // Reading attributes of the reply
  51. // e.g. the HTTP status code
  52. QVariant statusCodeV =
  53. mReply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
  54. // Or the target URL if it was a redirect:
  55. QVariant redirectionTargetUrl =
  56. mReply->attribute(QNetworkRequest::RedirectionTargetAttribute);
  57. // see CS001432 on how to handle this
  58.  
  59. // no error received?
  60. if (mReply->error() == QNetworkReply::NoError)
  61. {
  62. // read data from QNetworkReply here
  63. // Example 2: Reading bytes form the reply
  64. QByteArray bytes = mReply->readAll(); // bytes
  65. QString stringResponse(bytes); // string
  66.  
  67. qDebug() << "***** response *****" << stringResponse;
  68. }
  69. // Some http error received
  70. else
  71. {
  72. qDebug() << "***** reply http error =" <<(int) mReply->error();
  73.  
  74. QByteArray bytes = mReply->readAll(); // bytes
  75. QString stringResponse(bytes); // string
  76. qDebug() << "***** response *****" << stringResponse;
  77. }
  78.  
  79. // We receive ownership of the reply object
  80. // and therefore need to handle deletion.
  81. delete mReply;
  82. }
To copy to clipboard, switch view to plain text mode