Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QOAuth2AuthorizationCodeFlow and response
Qt 6.11 is out! See what's new in the release blog

QOAuth2AuthorizationCodeFlow and response

Scheduled Pinned Locked Moved Unsolved General and Desktop
oauth2.0
1 Posts 1 Posters 655 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CHIO-CHIO
    wrote on last edited by CHIO-CHIO
    #1

    Hello!
    I have some class for oauth2. When i launch, it open browser, i allow with terms, then it redirect me to page with auth code.

        this->oauth = new QOAuth2AuthorizationCodeFlow(this);
        connect(this->oauth, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, &QDesktopServices::openUrl);
    
    
        const QUrl authUri(".../oauth/authorize");
        const auto clientId = "...";
        const QUrl tokenUri(".../oauth/token");
        const auto clientSecret("...");
    
        this->oauth->setAuthorizationUrl(authUri);
        this->oauth->setClientIdentifier(clientId);
        this->oauth->setAccessTokenUrl(tokenUri);
        this->oauth->setClientIdentifierSharedKey(clientSecret);
    
        this->oauth->setModifyParametersFunction([](QAbstractOAuth::Stage stage, QVariantMap* parameters) {
            (*parameters)["redirect_uri"] = QUrl("urn:ietf:wg:oauth:2.0:oob");
            if (stage == QAbstractOAuth::Stage::RequestingAuthorization) { //if permament
                parameters->insert("duration", "permanent");
            }
         });
    
    
        connect(this->oauth, &QOAuth2AuthorizationCodeFlow::statusChanged, [](QAbstractOAuth::Status status) {
            qDebug() << "Status accepted";
        });
    
    
        connect(this->oauth, &QOAuth2AuthorizationCodeFlow::granted, [=](){
            qDebug() << __FUNCTION__ << __LINE__ << "Access Granted!";
    //        auto reply = this->oauth->get(whoami);
    //        connect(reply, &QNetworkReply::finished, [reply](){
    //            qDebug() << "REQUEST FINISHED. Error? " << (reply->error() != QNetworkReply::NoError);
    //            qDebug() << reply->readAll();
    //        });
        });
    
        this->oauth->grant();
    

    But i dont recive any response/callback. Is there any wrong here?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved