Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-81624

[OAuth] QOAuthHttpServerReplyHandler token double-encoding

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.13.1
    • None

    Description

      I've attached a test project to demonstrate the bug/problem.

      google = new QOAuth2AuthorizationCodeFlow;
      google->setScope("profile email");
      QObject::connect(google, &QOAuth2AuthorizationCodeFlow::authorizeWithBrowser, &QDesktopServices::openUrl);
      google->setClientIdentifier("SecretUser.apps.googleusercontent.com");
      google->setClientIdentifierSharedKey("GoogleSecretPass"); 
      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 use corporate mail "xxx@corp.nekki.ru", then (the qDebug's output is? - yes it is):

      grabreg "Token";

      If I use personal "xxx@gmail.com", then (I have an error):

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

      the problem is in the code that comes from the server

      ..."code", QVariant(QString, "4%2FvwF5px...
      

      namely, in "%2F". If in the readUrl method of the QOAuthHttpServerReplyHandler class I add a line
       

      if (!fragment.startsWith("/")) { 
          qDebug() << "Invalid URL path " << fragment.constData(); 
          return false; 
      } 
      fragment = fragment.replace("%2F", "/");
      

       
      then everything works.
       

      Attachments

        For Gerrit Dashboard: QTBUG-81624
        # Subject Branch Project Status CR V

        Activity

          People

            vuokko Juha Vuolle
            darth_anmiro Roman Milchakov
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There is 1 open Gerrit change