Commit 173cf7c6 authored by Krzysztof Nowicki's avatar Krzysztof Nowicki
Browse files

Reset OAuth2 access token when EWS request fails with 401

This most likely means that the OAuth2 access token is no longer
valid. Try to reset and refresh it.
parent 2d95adf5
......@@ -180,8 +180,10 @@ void EwsRequest::requestResult(KJob *job)
int resp = trJob->metaData()[QStringLiteral("responsecode")].toUInt();
#ifdef HAVE_NETWORKAUTH
if (resp == 401) {
if (resp == 401 && mClient.authMode() == EwsClient::OAuth2) {
qCInfo(EWSCLI_LOG) << QStringLiteral("Got HTTP 401 Unauthorized with OAuth - reset access token");
auto oAuth = mClient.oAuth();
oAuth->resetAccessToken();
if (oAuth->state() == EwsOAuth::NotAuthenticated || oAuth->state() == EwsOAuth::Authenticating) {
prepare(mBody);
return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment