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. Reddit Example failing
Qt 6.11 is out! See what's new in the release blog

Reddit Example failing

Scheduled Pinned Locked Moved Unsolved General and Desktop
20 Posts 4 Posters 2.7k Views 2 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #6

    There's no linking to be done. OpenSSL is dynamically loaded at run time. One thing you can to is to copy the dlls in the same folders as your application.

    The other is to modify the PATH environment variable in the Run part of the Project panel and add the folder that contains the dlls to it.

    By the way, which compiler are you using ?

    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
    1
    • H Offline
      H Offline
      HappyCerberus
      wrote on last edited by
      #7

      I'm still seeing this error in the output:

      qt.networkauth.oauth2: Unexpected call
      

      But it did succeed authenticating. I'm using Mingw.
      OK, so this at least works on Windows. Now to make it work on WSL2/Linux.

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

        What error are you getting 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
        • H Offline
          H Offline
          HappyCerberus
          wrote on last edited by
          #9

          On Linux I'm struggling with the entire process. I can't figure out where the redirect_uri is comming from.

          Because it's not generated from QOAuthHttpServerReplyHandler. If I manually change the URL to point to the correct IP i get qt.networkauth.oauth2: Error: invalid_grant, but I think that is expected.

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

            The URL is set in your Reddit application configuration on the website.

            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
            1
            • H Offline
              H Offline
              HappyCerberus
              wrote on last edited by
              #11

              Well, then something is broken in Qt. Because the redirect_uri definitely does not match what I set in my Reddit app.

              1 Reply Last reply
              0
              • H HappyCerberus

                I'm still seeing this error in the output:

                qt.networkauth.oauth2: Unexpected call
                

                But it did succeed authenticating. I'm using Mingw.
                OK, so this at least works on Windows. Now to make it work on WSL2/Linux.

                artwawA Offline
                artwawA Offline
                artwaw
                wrote on last edited by
                #12

                @HappyCerberus Please note that openSSL redistributed with Qt is for MSVC only. For use with MinGW you'd need to find precompiled binaries build with MinGW, version 1.1.1.4 (or 1.1.1.d), respectively x86 or x64. Or build them yourself.

                For more information please re-read.

                Kind Regards,
                Artur

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  HappyCerberus
                  wrote on last edited by
                  #13

                  @artwaw So, what you are saying is that the single case that I actually managed to get working is one that should not work :-D This is getting better and better :-)

                  artwawA 2 Replies Last reply
                  0
                  • H HappyCerberus

                    @artwaw So, what you are saying is that the single case that I actually managed to get working is one that should not work :-D This is getting better and better :-)

                    artwawA Offline
                    artwawA Offline
                    artwaw
                    wrote on last edited by
                    #14

                    @HappyCerberus It is a bit of a mystery for me too :) But I learned the hard way the first time they included OpenSSL in Qt and since then I don't rely this particular source.

                    For more information please re-read.

                    Kind Regards,
                    Artur

                    1 Reply Last reply
                    0
                    • H HappyCerberus

                      @artwaw So, what you are saying is that the single case that I actually managed to get working is one that should not work :-D This is getting better and better :-)

                      artwawA Offline
                      artwawA Offline
                      artwaw
                      wrote on last edited by
                      #15

                      @HappyCerberus I've de-dusted my old problems I had with SSL supplied via onlineinstaller - here goes the summary:

                      • I compile with MinGW on Windows. Always have been.
                      • once OpenSSL became available I was very happy, since it should simplify things. I began to use it but users reported to me that on some machines it doesn't work.
                      • I've spent quite some time debugging until I took a look into libraries provided. They're compiled with MSVC so they need MSVC libraries to run. If you have them installed, everything will work just fine. So if it worked, it worked but some of my users have not had those libs installed.
                      • Since then I stopped using bundled OpenSSL, as it is just potential additional overhead and more dependencies.

                      So if it worked for you, you simply had those Microsoft runtime libraries installed. But I'd check with dependency free MinGW compiled SSL libs too, just to be sure.

                      For more information please re-read.

                      Kind Regards,
                      Artur

                      1 Reply Last reply
                      0
                      • H Offline
                        H Offline
                        HappyCerberus
                        wrote on last edited by
                        #16

                        @artwaw Yeah, my problem now is that it doesn't work on Linux, and I suspect that it will not work because of the redirect_uri.

                        artwawA 1 Reply Last reply
                        0
                        • H HappyCerberus

                          @artwaw Yeah, my problem now is that it doesn't work on Linux, and I suspect that it will not work because of the redirect_uri.

                          artwawA Offline
                          artwawA Offline
                          artwaw
                          wrote on last edited by
                          #17

                          @HappyCerberus That's beyond my area of experience, I am afraid. Hopefully more experienced colleagues here can be of help.

                          For more information please re-read.

                          Kind Regards,
                          Artur

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

                            Do you get the same issue with a "classic" Linux rather than WSL2 ?

                            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
                            • H Offline
                              H Offline
                              HappyCerberus
                              wrote on last edited by
                              #19

                              Yeah, unfortunately the redirect_uri is again wrong and when I manually change it I get:

                              qt.networkauth.oauth2: Unexpected call
                              qt.networkauth.oauth2: Error: invalid_grant
                              
                              1 Reply Last reply
                              0
                              • U Offline
                                U Offline
                                unseemlysloth
                                wrote on last edited by
                                #20

                                I was having the same problem.

                                I had to manually set the redirect_uri for the RequestingAuthorization stage to just get that first part to work.

                                After that I get the same invalid_grant error.

                                The reddit api says that you get this error if you use an expired code, or reuse a code. Apparently though, you also get it if the redirect_uris in both the RequestingAuthorization stage and the RequestingAccessToken stage don't match.

                                    oauth2.setModifyParametersFunction([&](QAbstractOAuth::Stage stage, QVariantMap *parameters) {
                                        if(stage == QAbstractOAuth::Stage::RequestingAuthorization) {
                                            parameters->insert("duration", "permanent");
                                            parameters->insert("redirect_uri", QByteArray("http://127.0.0.1:1337"));
                                        } else if(stage == QAbstractOAuth::Stage::RequestingAccessToken) {
                                            parameters->insert("redirect_uri", QByteArray("http://127.0.0.1:1337"));
                                        }
                                    });
                                

                                That seems to have worked.

                                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