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. Google oAuth invalid QOAuthHttpServerReplyHandler
QtWS25 Last Chance

Google oAuth invalid QOAuthHttpServerReplyHandler

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 583 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.
  • D Offline
    D Offline
    Darth_Anmiro
    wrote on last edited by Darth_Anmiro
    #1

    Hello.

    google = new QOAuth2AuthorizationCodeFlow;
    google->setScope("profile email");
    QObject::connect(google, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser,
                     &QDesktopServices::openUrl);
    
    google->setClientIdentifier("topSecretUser"
                                "apps.googleusercontent.com");
    google->setClientIdentifierSharedKey("TopSecretPassword");
    google->setAuthorizationUrl(
        QUrl("https://accounts.google.com/o/oauth2/auth"));
    google->setAccessTokenUrl(QUrl("https://oauth2.googleapis.com/token"));
    
    replyHandler = new QOAuthHttpServerReplyHandler();
    google->setReplyHandler(replyHandler);
    google->grant();
    
    QObject::connect(google, &QOAuth2AuthorizationCodeFlow::granted,
                     [this] { qDebug() << "grabreg" << google->token(); });
    

    If i selected my personal e-mail then i see

    qt.networkauth.replyhandler: Error transferring https://oauth2.googleapis.com/token - server replied: Bad Request
    

    If i selected my work e-mail then noraml autorization and i got goole token and can get profile and another user information.

    What i doing wrong?
    Thanks to everyone.

    Pablo J. RoginaP O 2 Replies Last reply
    0
    • D Darth_Anmiro

      Hello.

      google = new QOAuth2AuthorizationCodeFlow;
      google->setScope("profile email");
      QObject::connect(google, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser,
                       &QDesktopServices::openUrl);
      
      google->setClientIdentifier("topSecretUser"
                                  "apps.googleusercontent.com");
      google->setClientIdentifierSharedKey("TopSecretPassword");
      google->setAuthorizationUrl(
          QUrl("https://accounts.google.com/o/oauth2/auth"));
      google->setAccessTokenUrl(QUrl("https://oauth2.googleapis.com/token"));
      
      replyHandler = new QOAuthHttpServerReplyHandler();
      google->setReplyHandler(replyHandler);
      google->grant();
      
      QObject::connect(google, &QOAuth2AuthorizationCodeFlow::granted,
                       [this] { qDebug() << "grabreg" << google->token(); });
      

      If i selected my personal e-mail then i see

      qt.networkauth.replyhandler: Error transferring https://oauth2.googleapis.com/token - server replied: Bad Request
      

      If i selected my work e-mail then noraml autorization and i got goole token and can get profile and another user information.

      What i doing wrong?
      Thanks to everyone.

      Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #2

      @Darth_Anmiro said in Google oAuth invalid QOAuthHttpServerReplyHandler:

      If i selected my work e-mail then noraml autorization and i got goole token and can get profile and another user information

      Should that be a property of the authorization service your accessing? I mean, it works with a work e-mail, it doesn't work with a personal e-mail...

      What i doing wrong?

      Wouldn't it better asking on Google Auth forum?

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      D 1 Reply Last reply
      0
      • Pablo J. RoginaP Pablo J. Rogina

        @Darth_Anmiro said in Google oAuth invalid QOAuthHttpServerReplyHandler:

        If i selected my work e-mail then noraml autorization and i got goole token and can get profile and another user information

        Should that be a property of the authorization service your accessing? I mean, it works with a work e-mail, it doesn't work with a personal e-mail...

        What i doing wrong?

        Wouldn't it better asking on Google Auth forum?

        D Offline
        D Offline
        Darth_Anmiro
        wrote on last edited by Darth_Anmiro
        #3

        @Pablo-J-Rogina

        No, google service is configured for external users and created in my personal account. And google credentials selected other.
        As I understand it, no one has encountered such a problem?
        I would ask, but here QOAuthHttpServerReplyHandler, so I decided to start with the qt forum first

        1 Reply Last reply
        0
        • D Offline
          D Offline
          Darth_Anmiro
          wrote on last edited by
          #4

          Problem with code, i would create bug on qt bugs, and i hope they fix it

          1 Reply Last reply
          0
          • D Darth_Anmiro

            Hello.

            google = new QOAuth2AuthorizationCodeFlow;
            google->setScope("profile email");
            QObject::connect(google, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser,
                             &QDesktopServices::openUrl);
            
            google->setClientIdentifier("topSecretUser"
                                        "apps.googleusercontent.com");
            google->setClientIdentifierSharedKey("TopSecretPassword");
            google->setAuthorizationUrl(
                QUrl("https://accounts.google.com/o/oauth2/auth"));
            google->setAccessTokenUrl(QUrl("https://oauth2.googleapis.com/token"));
            
            replyHandler = new QOAuthHttpServerReplyHandler();
            google->setReplyHandler(replyHandler);
            google->grant();
            
            QObject::connect(google, &QOAuth2AuthorizationCodeFlow::granted,
                             [this] { qDebug() << "grabreg" << google->token(); });
            

            If i selected my personal e-mail then i see

            qt.networkauth.replyhandler: Error transferring https://oauth2.googleapis.com/token - server replied: Bad Request
            

            If i selected my work e-mail then noraml autorization and i got goole token and can get profile and another user information.

            What i doing wrong?
            Thanks to everyone.

            O Offline
            O Offline
            orio
            wrote on last edited by
            #5

            had the same problem, trying to solve it in a different way .
            if you don't care using the consent screen each time you can try :

            QOAuth2AuthorizationCodeFlow oauth ;// (not sure about syntax)
            ...
            ...
            ..
             connect(oauth , &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, [=](QUrl url) {
                    QUrlQuery query(url);
                    query.addQueryItem("prompt", "consent");      // Param required to get data everytime
                    query.addQueryItem("access_type", "offline"); // Needed for Refresh Token (as AccessToken expires shortly)
                    url.setQuery(query);
            
                    QDesktopServices::openUrl(url);
                });
            

            found it at stackoverflow cant find the link now.

            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