void OAuthenticator::RefreshAccessTokenFinished(QNetworkReply* reply) { reply->deleteLater(); QJson::Parser parser; bool ok = false; QVariantMap result = parser.parse(reply, &ok).toMap(); access_token_ = result["access_token"].toString(); if (result.contains("refresh_token")) { refresh_token_ = result["refresh_token"].toString(); } SetExpiryTime(result["expires_in"].toInt()); emit Finished(); }
void OAuthenticator::FetchAccessTokenFinished(QNetworkReply* reply) { reply->deleteLater(); if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) != 200) { qLog(Error) << "Failed to get access token" << reply->readAll(); return; } QJson::Parser parser; bool ok = false; QVariantMap result = parser.parse(reply, &ok).toMap(); if (!ok) { qLog(Error) << "Failed to parse oauth reply"; return; } access_token_ = result["access_token"].toString(); refresh_token_ = result["refresh_token"].toString(); SetExpiryTime(result["expires_in"].toInt()); emit Finished(); }