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 fails without message. How to debug?
Qt 6.11 is out! See what's new in the release blog

QOAuth2AuthorizationCodeFlow fails without message. How to debug?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 1.3k Views 1 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.
  • A Offline
    A Offline
    aphot
    wrote on last edited by
    #1

    Hi,

    I am trying to connect with the digikey webshop though my application. It worked very well for months until now. I didn't even recompiled the binary, so I don't know what changed, whether it was the shop or maybe an windows-update interfered in the past.
    Some Facts:
    Digikey: https://developer.digikey.com/documentation/oauth
    Tried with Qt 5.14.2(windows) and 5.12.8(linux)

    Logging is activated:

    QLoggingCategory::setFilterRules("qt.networkauth.*=true");
    

    Now when I call the function grant():

    DigikeyWrapper::DigikeyWrapper(const Settings &settings, QObject *parent)
        : QObject(parent)
        , m_settings(settings) {
        auto replyHandler = new QOAuthHttpServerReplyHandler(1337, this);
        oauth2.setReplyHandler(replyHandler);
        oauth2.setAuthorizationUrl(QUrl(m_settings.get_digikey_url_string() + "/v1/oauth2/authorize"));
        oauth2.setAccessTokenUrl(QUrl(m_settings.get_digikey_url_string() + "/v1/oauth2/token"));
        oauth2.setScope("identity read");
        oauth2.setClientIdentifier(m_settings.get_digikey_clientID());
        oauth2.setClientIdentifierSharedKey(m_settings.get_digikey_secret());
    
        network_manager = new QNetworkAccessManager(this);
        connect(&oauth2, &QOAuth2AuthorizationCodeFlow::statusChanged, [=](QAbstractOAuth::Status status) {
            qDebug() << "statusChanged";
            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);
    
        connect(this, &DigikeyWrapper::authenticated, this, &DigikeyWrapper::just_authenticated);
    }
    
    void DigikeyWrapper::grant() {
        qDebug() << "granting..";
        oauth2.grant();
    }
    

    The browser window opens but is completely empty. Normally I should see a mask to enter my shop credentials.
    The console says:

    granting..
    qt.networkauth.oauth2: Generated URL: https://api.digikey.com/v1/oauth2/authorize?client_id=xxxxxxxx&redirect_uri=http://127.0.0.1:1337/&response_type=code&scope=identity read&state=8E4ntqBX
    onecore\com\combase\catalog\catalog.cxx(1026)\combase.dll!00007FF94979A4F6: (caller: 00007FF9497B9472) ReturnHr(1) tid(2500) 80070716 Der angegebene Ressourcenname wurde nicht in der Image-Datei gefunden.
    onecore\com\combase\inc\ComCatalogHelpers.hpp(60)\combase.dll!00007FF9497B94F9: (caller: 00007FF9497B7FF8) ReturnHr(2) tid(2500) 80070716 Der angegebene Ressourcenname wurde nicht in der Image-Datei gefunden.
    
    

    If I try the same interface from a python program everything works as expected. This confirms that Digikey is still working.

    Unfortunately I don't get any error message except the combase.dll errors where i don't have any clue what this means. Do you have any idea how to debug that issue?

    Thank you for ideas,
    Aphot

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      What about the error message on Linux ?

      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
      • A Offline
        A Offline
        aphot
        wrote on last edited by
        #3

        Hi,

        its been i while i didnt work on the project. The branch I use on linux generates mostly the same log:

        granting..
        
        qt.networkauth.oauth2: Generated URL: https://api.digikey.com/v1/oauth2/authorize?client_id=xxx&redirect_uri=http://127.0.0.1:1337/&response_type=code&scope=identity read&state=zNpwF7xT
        

        I also checked the empty page i get from Digikey, where I should see the logingscreen, and also the html souce code is empty.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Do you mean the login page is empty ?

          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
          • A Offline
            A Offline
            aphot
            wrote on last edited by
            #5

            yes, zero bytes

            1 Reply Last reply
            0
            • A Offline
              A Offline
              aphot
              wrote on last edited by
              #6

              Ok, I just was trying around and deleted the line setting the scope.
              It works this way. Dont know why, but it works. Little funny side fact: The login page is on japanese now, but I can login :-)

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Authentication is sometime mysterious...

                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

                • Login

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