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. OAuth0 QNetworkAuth
QtWS25 Last Chance

OAuth0 QNetworkAuth

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 2.1k 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.
  • J Offline
    J Offline
    JVargas
    wrote on last edited by
    #1

    Hello everyone in the community,
    I, as a newbie, need a bit of help to understand qnetworkauth, specifically with oauth0.

    I am successfully logging against oauth basing myself on qt webpage's example.

    connect(m_oauth, &QOAuth2AuthorizationCodeFlow::statusChanged, [=](QAbstractOAuth::Status status)
            {
    	if (status == QAbstractOAuth::Status::TemporaryCredentialsReceived)
    				emit authenticated();
            });
    

    Now the 2 questions:

    • How can I get my user info from my endpoint?

    I was trying something like this:

    void Authorization::getUserInfo()
        {
    		QString newUrl{ "https://mydomain.auth0.com/userinfo?access_token=" };
            newUrl.append(m_oauth->token());
    
            auto reply = m_oauth->get(QUrl(newUrl));
    
            connect(reply, &QNetworkReply::finished, [=]() { ... });
    }
    
    • And finally, how can I send my token together with my requests to my webservice?

    Thank you very much!

    raven-worxR 2 Replies Last reply
    0
    • J JVargas

      Hello everyone in the community,
      I, as a newbie, need a bit of help to understand qnetworkauth, specifically with oauth0.

      I am successfully logging against oauth basing myself on qt webpage's example.

      connect(m_oauth, &QOAuth2AuthorizationCodeFlow::statusChanged, [=](QAbstractOAuth::Status status)
              {
      	if (status == QAbstractOAuth::Status::TemporaryCredentialsReceived)
      				emit authenticated();
              });
      

      Now the 2 questions:

      • How can I get my user info from my endpoint?

      I was trying something like this:

      void Authorization::getUserInfo()
          {
      		QString newUrl{ "https://mydomain.auth0.com/userinfo?access_token=" };
              newUrl.append(m_oauth->token());
      
              auto reply = m_oauth->get(QUrl(newUrl));
      
              connect(reply, &QNetworkReply::finished, [=]() { ... });
      }
      
      • And finally, how can I send my token together with my requests to my webservice?

      Thank you very much!

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @JVargas said in OAuth0 QNetworkAuth:

      • How can I get my user info from my endpoint?

      I was trying something like this:
      ...

      • And finally, how can I send my token together with my requests to my webservice?

      are there any errors? Does it work or not? I don't see the actual question here? Or is it just a design-related question?
      What is your endpoint?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JVargas
        wrote on last edited by
        #3

        Raven, thank you for you answer.
        No, it doesn't work. After I got the TemporaryCredentialsReceived, my m_oauth->token() is empty.
        Am I doing something wrong?

        Thank you
        Jhonny Vargas

        1 Reply Last reply
        0
        • J JVargas

          Hello everyone in the community,
          I, as a newbie, need a bit of help to understand qnetworkauth, specifically with oauth0.

          I am successfully logging against oauth basing myself on qt webpage's example.

          connect(m_oauth, &QOAuth2AuthorizationCodeFlow::statusChanged, [=](QAbstractOAuth::Status status)
                  {
          	if (status == QAbstractOAuth::Status::TemporaryCredentialsReceived)
          				emit authenticated();
                  });
          

          Now the 2 questions:

          • How can I get my user info from my endpoint?

          I was trying something like this:

          void Authorization::getUserInfo()
              {
          		QString newUrl{ "https://mydomain.auth0.com/userinfo?access_token=" };
                  newUrl.append(m_oauth->token());
          
                  auto reply = m_oauth->get(QUrl(newUrl));
          
                  connect(reply, &QNetworkReply::finished, [=]() { ... });
          }
          
          • And finally, how can I send my token together with my requests to my webservice?

          Thank you very much!

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          what service are you using for authentication?

          @JVargas said in OAuth0 QNetworkAuth:

          if (status == QAbstractOAuth::Status::TemporaryCredentialsReceived)
          emit authenticated();

          this looks like you assume a successful authentication upon the TemporaryCredentialsReceived status. But i think this can't be expected as the name of the status implies. You need the QAbstractOAuth::Granted status for a successful authentication. Thus something more has to be done upon receiving the TemporaryCredentialsReceived status.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • J Offline
            J Offline
            JVargas
            wrote on last edited by
            #5

            Oh I see.
            I believe that I need to investigate a bit more.
            Thank you for your patience raven =)

            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