Accessing Microsoft Graph API with the Qt Network Authentication module
-
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_testThe 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!
-
@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?
-
@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#L62I 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. -
Any idea?