I want to use QtNetworkAuthorization to grant access to some resources by REST APIs.The server I want to connect to uses Oauth1. There are examples of Qt Network Authorization but using the old interfaces of QOauth. The example in official SDK is showing example of Twitter but it requires GUI application to use QDesktopServices and Twitter does not use verifier. It automatically grants access when user allow access.

What I want to do requires 3 steps.

1) Using the request_token query with clientID and clientSecret get temporary credentials.

2) Using the clientID,clientSecret and tempToken,tempSecret ask user to open constentData url where a verifier code is shown user. The user copies it.

3)Using the verifier,clientID and temporary credentials our app requests for permanent credentials.So far using QOAuth1 my code is :

Qt Code:
  1. const QString request_token_url = "https://sandboxapi.deere.com/platform/oauth/request_token";
  2. QString request_token_query_args = "oauth_callback=oob";
  3. QString authorize_url_base ="https://my.deere.com/consentToUseOfData";
  4. const QString access_token_url = "https://sandboxapi.deere.com/platform/oauth/access_token";
  5. QNetworkAccessManager * manager = new QNetworkAccessManager();
  6.  
  7. QString base_request_token_url = request_token_url + (request_token_query_args.isEmpty() ? "" : ("?"+request_token_query_args) );
  8. QOAuth1 * oth = new QOAuth1(&a);
  9. oth->setSignatureMethod(QOAuth1::SignatureMethod::Hmac_Sha1);
  10. oth->setClientIdentifier(client_key);
  11. oth->setClientSharedSecret(client_secret);
  12. oth->setTemporaryCredentialsUrl(request_token_url);
  13. oth->setAuthorizationUrl(authorize_url_base);
  14. oth->setTokenCredentialsUrl(QUrl(access_token_url));
  15.  
  16. oth->setReplyHandler(new QOAuthOobReplyHandler());
  17. oth->setContentType(QOAuth1::ContentType::Json);
  18.  
  19. oth->setNetworkAccessManager(manager);
  20.  
  21. oth->grant();
  22. QObject::connect(oth,&QOAuth1::granted,[](){
  23.  
  24. cout<<"granted "<<endl;
  25. });
  26.  
  27. QObject::connect(oth->replyHandler(),&QAbstractOAuthReplyHandler::tokensReceived,[](){
  28. qDebug()<<"token received";
  29. });
  30.  
  31. QObject::connect(manager,&QNetworkAccessManager::finished,[oth,authorize_url_base](QNetworkReply * reply){
  32.  
  33. auto result=reply->readAll();
  34. auto tokenSecretPair=result.split('&');
  35.  
  36. auto token = tokenSecretPair[0].split('=');
  37. auto secret = tokenSecretPair[1].split('=');
  38. qDebug()<<token<<" "<<secret;
  39. oth->setTokenCredentials(token[1],secret[1]);
  40. qDebug()<<oth->tokenCredentials();
  41. });
To copy to clipboard, switch view to plain text mode 

With this piece of code, I am only able to get temporary credentials. I can not pass to second step to ask for user verifier. There are methods in implementation like requestTemporaryTokens but they are protected. Also there is no function to setVerifier in QOauth1.

How can I access use QOAuth1 to pass all three steps of authentication ?