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. Accessing Microsoft Graph API with the Qt Network Authentication module
Forum Updated to NodeBB v4.3 + New Features

Accessing Microsoft Graph API with the Qt Network Authentication module

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 997 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.
  • M Offline
    M Offline
    martonmiklos
    wrote on last edited by
    #1

    Hello all,

    I am trying to access my OneNote notes through the Microsoft's Graph API.

    I have started from the redditclient example, my code lives here:
    https://github.com/martonmiklos/qt_ms_graph_api_test

    The token exchange seems to be working the MS login page opens in the browser, and logins fine.

    However the requests after the authentication fail with:

    QNetworkReply::AuthenticationRequiredError "Host requires authentication" "{
      "error": {
        "code": "InvalidAuthenticationToken",
        "message": "Access token validation failure. Invalid audience.",
        "innerError": {
          "request-id": "9328d369-0d27-4aae-b7a6-fa2b3773e6d1",
          "date": "2020-03-10T15:21:58"
        }
      }
    

    }"

    I have tried to add the resource parameter as suggested here https://stackoverflow.com/questions/50748492/how-can-i-use-qt-network-authorization-for-azure-ad-oauth2

    Any hint would be welcome!

    raven-worxR 1 Reply Last reply
    0
    • M martonmiklos

      Hello all,

      I am trying to access my OneNote notes through the Microsoft's Graph API.

      I have started from the redditclient example, my code lives here:
      https://github.com/martonmiklos/qt_ms_graph_api_test

      The token exchange seems to be working the MS login page opens in the browser, and logins fine.

      However the requests after the authentication fail with:

      QNetworkReply::AuthenticationRequiredError "Host requires authentication" "{
        "error": {
          "code": "InvalidAuthenticationToken",
          "message": "Access token validation failure. Invalid audience.",
          "innerError": {
            "request-id": "9328d369-0d27-4aae-b7a6-fa2b3773e6d1",
            "date": "2020-03-10T15:21:58"
          }
        }
      

      }"

      I have tried to add the resource parameter as suggested here https://stackoverflow.com/questions/50748492/how-can-i-use-qt-network-authorization-for-azure-ad-oauth2

      Any hint would be welcome!

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

      @martonmiklos said in Accessing Microsoft Graph API with the Qt Network Authentication module:

      However the requests after the authentication fail with

      seems you are using the wrong QNetworkAccessManager (missing the cookies) maybe?

      --- 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

      M 1 Reply Last reply
      0
      • raven-worxR raven-worx

        @martonmiklos said in Accessing Microsoft Graph API with the Qt Network Authentication module:

        However the requests after the authentication fail with

        seems you are using the wrong QNetworkAccessManager (missing the cookies) maybe?

        M Offline
        M Offline
        martonmiklos
        wrote on last edited by
        #3

        @raven-worx many thanks for your answer!

        How do you mean that I am using the wrong QNetworkAccessManager?

        Here you can see the relevant snipplet:
        https://github.com/martonmiklos/qt_ms_graph_api_test/blob/master/redditwrapper.cpp#L62

        I think the authentiaction phase goes correctly because the oauth2 (QOAuth2AuthorizationCodeFlow) object emits statusChanged with QAbstractOAuth::TemporaryCredentialsReceived -> QAbstractOAuth::Granted states.

        In line 88:
        https://github.com/martonmiklos/qt_ms_graph_api_test/blob/master/redditwrapper.cpp#L88
        I call a simple get through the same QOAuth2AuthorizationCodeFlow object.

        M 1 Reply Last reply
        0
        • M martonmiklos

          @raven-worx many thanks for your answer!

          How do you mean that I am using the wrong QNetworkAccessManager?

          Here you can see the relevant snipplet:
          https://github.com/martonmiklos/qt_ms_graph_api_test/blob/master/redditwrapper.cpp#L62

          I think the authentiaction phase goes correctly because the oauth2 (QOAuth2AuthorizationCodeFlow) object emits statusChanged with QAbstractOAuth::TemporaryCredentialsReceived -> QAbstractOAuth::Granted states.

          In line 88:
          https://github.com/martonmiklos/qt_ms_graph_api_test/blob/master/redditwrapper.cpp#L88
          I call a simple get through the same QOAuth2AuthorizationCodeFlow object.

          M Offline
          M Offline
          martonmiklos
          wrote on last edited by
          #4

          Any idea?

          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