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. Oauth2 with code and token
Qt 6.11 is out! See what's new in the release blog

Oauth2 with code and token

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 462 Views 3 Watching
  • 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.
  • P Offline
    P Offline
    Pinky
    wrote on last edited by
    #1

    I try to get the code from an API to request a token. I can't read out the code provided by the redirect url (with my qt app).

    The browser opens and I can loging but afterwards the QT does not get the code and I cannot authenticate further. The code is based on the reddit example.

    Might someone has an idea?

    oauth2.setAuthorizationUrl(QUrl(".../oauth/authorize"));
    oauth2.setAccessTokenUrl(QUrl("..../oauth/token"));
    oauth2.setScope("READSYSTEM");
    oauth2.setClientIdentifier("10ba4ca31a5344868b32fe3f36576e00");
    oauth2.setClientIdentifierSharedKey("qX+JBXrc2973loCZ9HeZ0JP1P7QqyM9vCRwr9sBH/hI=");
    
    auto replyHandler = new myReplyHandler(this);
    oauth2.setReplyHandler(replyHandler);
    

    I have my own callback written for redirect url. I cannot use localhost for that specific application.

    connect(&oauth2, &QOAuth2AuthorizationCodeFlow::statusChanged, [=](
               QAbstractOAuth::Status status) {
           if (status == QAbstractOAuth::Status::Granted)
               emit authenticated();
       });
       oauth2.setModifyParametersFunction([&](QAbstractOAuth::Stage stage, QVariantMap *parameters) {
           if (stage == QAbstractOAuth::Stage::RequestingAuthorization && isPermanent())
               parameters->insert("duration", "permanent");
       });
       connect(&oauth2, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser,
               &QDesktopServices::openUrl);
    
    oauth2->grant();
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Can you explain exactly what happens after you sign in successfully ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Pinky
        wrote on last edited by
        #3

        When I have signed (on the authentication page) in and clicked on the captcha I will be redirected to the url where I can get the code. The code is there and I see the message in the browser. But I should receive it directly in my program parse it and further use for the oauth process.

        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