Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Google oAuth invalid QOAuthHttpServerReplyHandler

    General and Desktop
    3
    5
    328
    Loading More Posts
    • 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
      Darth_Anmiro last edited by 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. Rogina O 2 Replies Last reply Reply Quote 0
      • Pablo J. Rogina
        Pablo J. Rogina @Darth_Anmiro last edited by

        @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 Reply Quote 0
        • D
          Darth_Anmiro @Pablo J. Rogina last edited by Darth_Anmiro

          @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 Reply Quote 0
          • D
            Darth_Anmiro last edited by

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

            1 Reply Last reply Reply Quote 0
            • O
              orio @Darth_Anmiro last edited by

              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 Reply Quote 0
              • First post
                Last post