Merge pull request #2416 from Trial97/retry_auth
This commit is contained in:
commit
ebd7974fcc
@ -10,6 +10,7 @@
|
|||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "minecraft/auth/Parsers.h"
|
#include "minecraft/auth/Parsers.h"
|
||||||
#include "net/Download.h"
|
#include "net/Download.h"
|
||||||
|
#include "net/NetJob.h"
|
||||||
#include "net/StaticHeaderProxy.h"
|
#include "net/StaticHeaderProxy.h"
|
||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
|
|
||||||
@ -31,12 +32,15 @@ void EntitlementsStep::perform()
|
|||||||
{ "Authorization", QString("Bearer %1").arg(m_data->yggdrasilToken.token).toUtf8() } };
|
{ "Authorization", QString("Bearer %1").arg(m_data->yggdrasilToken.token).toUtf8() } };
|
||||||
|
|
||||||
m_response.reset(new QByteArray());
|
m_response.reset(new QByteArray());
|
||||||
m_task = Net::Download::makeByteArray(url, m_response);
|
m_request = Net::Download::makeByteArray(url, m_response);
|
||||||
m_task->addHeaderProxy(new Net::StaticHeaderProxy(headers));
|
m_request->addHeaderProxy(new Net::StaticHeaderProxy(headers));
|
||||||
|
|
||||||
|
m_task.reset(new NetJob("EntitlementsStep", APPLICATION->network()));
|
||||||
|
m_task->setAskRetry(false);
|
||||||
|
m_task->addNetAction(m_request);
|
||||||
|
|
||||||
connect(m_task.get(), &Task::finished, this, &EntitlementsStep::onRequestDone);
|
connect(m_task.get(), &Task::finished, this, &EntitlementsStep::onRequestDone);
|
||||||
|
|
||||||
m_task->setNetwork(APPLICATION->network());
|
|
||||||
m_task->start();
|
m_task->start();
|
||||||
qDebug() << "Getting entitlements...";
|
qDebug() << "Getting entitlements...";
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "minecraft/auth/AuthStep.h"
|
#include "minecraft/auth/AuthStep.h"
|
||||||
#include "net/Download.h"
|
#include "net/Download.h"
|
||||||
|
#include "net/NetJob.h"
|
||||||
|
|
||||||
class EntitlementsStep : public AuthStep {
|
class EntitlementsStep : public AuthStep {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -22,5 +23,6 @@ class EntitlementsStep : public AuthStep {
|
|||||||
private:
|
private:
|
||||||
QString m_entitlements_request_id;
|
QString m_entitlements_request_id;
|
||||||
std::shared_ptr<QByteArray> m_response;
|
std::shared_ptr<QByteArray> m_response;
|
||||||
Net::Download::Ptr m_task;
|
Net::Download::Ptr m_request;
|
||||||
|
NetJob::Ptr m_task;
|
||||||
};
|
};
|
||||||
|
@ -17,17 +17,20 @@ void GetSkinStep::perform()
|
|||||||
QUrl url(m_data->minecraftProfile.skin.url);
|
QUrl url(m_data->minecraftProfile.skin.url);
|
||||||
|
|
||||||
m_response.reset(new QByteArray());
|
m_response.reset(new QByteArray());
|
||||||
m_task = Net::Download::makeByteArray(url, m_response);
|
m_request = Net::Download::makeByteArray(url, m_response);
|
||||||
|
|
||||||
|
m_task.reset(new NetJob("GetSkinStep", APPLICATION->network()));
|
||||||
|
m_task->setAskRetry(false);
|
||||||
|
m_task->addNetAction(m_request);
|
||||||
|
|
||||||
connect(m_task.get(), &Task::finished, this, &GetSkinStep::onRequestDone);
|
connect(m_task.get(), &Task::finished, this, &GetSkinStep::onRequestDone);
|
||||||
|
|
||||||
m_task->setNetwork(APPLICATION->network());
|
|
||||||
m_task->start();
|
m_task->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetSkinStep::onRequestDone()
|
void GetSkinStep::onRequestDone()
|
||||||
{
|
{
|
||||||
if (m_task->error() == QNetworkReply::NoError)
|
if (m_request->error() == QNetworkReply::NoError)
|
||||||
m_data->minecraftProfile.skin.data = *m_response;
|
m_data->minecraftProfile.skin.data = *m_response;
|
||||||
emit finished(AccountTaskState::STATE_WORKING, tr("Got skin"));
|
emit finished(AccountTaskState::STATE_WORKING, tr("Got skin"));
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "minecraft/auth/AuthStep.h"
|
#include "minecraft/auth/AuthStep.h"
|
||||||
#include "net/Download.h"
|
#include "net/Download.h"
|
||||||
|
#include "net/NetJob.h"
|
||||||
|
|
||||||
class GetSkinStep : public AuthStep {
|
class GetSkinStep : public AuthStep {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -21,5 +22,6 @@ class GetSkinStep : public AuthStep {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<QByteArray> m_response;
|
std::shared_ptr<QByteArray> m_response;
|
||||||
Net::Download::Ptr m_task;
|
Net::Download::Ptr m_request;
|
||||||
|
NetJob::Ptr m_task;
|
||||||
};
|
};
|
||||||
|
@ -37,12 +37,15 @@ void LauncherLoginStep::perform()
|
|||||||
};
|
};
|
||||||
|
|
||||||
m_response.reset(new QByteArray());
|
m_response.reset(new QByteArray());
|
||||||
m_task = Net::Upload::makeByteArray(url, m_response, requestBody.toUtf8());
|
m_request = Net::Upload::makeByteArray(url, m_response, requestBody.toUtf8());
|
||||||
m_task->addHeaderProxy(new Net::StaticHeaderProxy(headers));
|
m_request->addHeaderProxy(new Net::StaticHeaderProxy(headers));
|
||||||
|
|
||||||
|
m_task.reset(new NetJob("LauncherLoginStep", APPLICATION->network()));
|
||||||
|
m_task->setAskRetry(false);
|
||||||
|
m_task->addNetAction(m_request);
|
||||||
|
|
||||||
connect(m_task.get(), &Task::finished, this, &LauncherLoginStep::onRequestDone);
|
connect(m_task.get(), &Task::finished, this, &LauncherLoginStep::onRequestDone);
|
||||||
|
|
||||||
m_task->setNetwork(APPLICATION->network());
|
|
||||||
m_task->start();
|
m_task->start();
|
||||||
qDebug() << "Getting Minecraft access token...";
|
qDebug() << "Getting Minecraft access token...";
|
||||||
}
|
}
|
||||||
@ -50,12 +53,13 @@ void LauncherLoginStep::perform()
|
|||||||
void LauncherLoginStep::onRequestDone()
|
void LauncherLoginStep::onRequestDone()
|
||||||
{
|
{
|
||||||
qCDebug(authCredentials()) << *m_response;
|
qCDebug(authCredentials()) << *m_response;
|
||||||
if (m_task->error() != QNetworkReply::NoError) {
|
if (m_request->error() != QNetworkReply::NoError) {
|
||||||
qWarning() << "Reply error:" << m_task->error();
|
qWarning() << "Reply error:" << m_request->error();
|
||||||
if (Net::isApplicationError(m_task->error())) {
|
if (Net::isApplicationError(m_request->error())) {
|
||||||
emit finished(AccountTaskState::STATE_FAILED_SOFT, tr("Failed to get Minecraft access token: %1").arg(m_task->errorString()));
|
emit finished(AccountTaskState::STATE_FAILED_SOFT,
|
||||||
|
tr("Failed to get Minecraft access token: %1").arg(m_request->errorString()));
|
||||||
} else {
|
} else {
|
||||||
emit finished(AccountTaskState::STATE_OFFLINE, tr("Failed to get Minecraft access token: %1").arg(m_task->errorString()));
|
emit finished(AccountTaskState::STATE_OFFLINE, tr("Failed to get Minecraft access token: %1").arg(m_request->errorString()));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "minecraft/auth/AuthStep.h"
|
#include "minecraft/auth/AuthStep.h"
|
||||||
|
#include "net/NetJob.h"
|
||||||
#include "net/Upload.h"
|
#include "net/Upload.h"
|
||||||
|
|
||||||
class LauncherLoginStep : public AuthStep {
|
class LauncherLoginStep : public AuthStep {
|
||||||
@ -21,5 +22,6 @@ class LauncherLoginStep : public AuthStep {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<QByteArray> m_response;
|
std::shared_ptr<QByteArray> m_response;
|
||||||
Net::Upload::Ptr m_task;
|
Net::Upload::Ptr m_request;
|
||||||
|
NetJob::Ptr m_task;
|
||||||
};
|
};
|
||||||
|
@ -67,12 +67,15 @@ void MSADeviceCodeStep::perform()
|
|||||||
{ "Accept", "application/json" },
|
{ "Accept", "application/json" },
|
||||||
};
|
};
|
||||||
m_response.reset(new QByteArray());
|
m_response.reset(new QByteArray());
|
||||||
m_task = Net::Upload::makeByteArray(url, m_response, payload);
|
m_request = Net::Upload::makeByteArray(url, m_response, payload);
|
||||||
m_task->addHeaderProxy(new Net::StaticHeaderProxy(headers));
|
m_request->addHeaderProxy(new Net::StaticHeaderProxy(headers));
|
||||||
|
|
||||||
|
m_task.reset(new NetJob("MSADeviceCodeStep", APPLICATION->network()));
|
||||||
|
m_task->setAskRetry(false);
|
||||||
|
m_task->addNetAction(m_request);
|
||||||
|
|
||||||
connect(m_task.get(), &Task::finished, this, &MSADeviceCodeStep::deviceAutorizationFinished);
|
connect(m_task.get(), &Task::finished, this, &MSADeviceCodeStep::deviceAutorizationFinished);
|
||||||
|
|
||||||
m_task->setNetwork(APPLICATION->network());
|
|
||||||
m_task->start();
|
m_task->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +120,7 @@ void MSADeviceCodeStep::deviceAutorizationFinished()
|
|||||||
tr("Device authorization failed: %1").arg(rsp.error_description.isEmpty() ? rsp.error : rsp.error_description));
|
tr("Device authorization failed: %1").arg(rsp.error_description.isEmpty() ? rsp.error : rsp.error_description));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!m_task->wasSuccessful() || m_task->error() != QNetworkReply::NoError) {
|
if (!m_request->wasSuccessful() || m_request->error() != QNetworkReply::NoError) {
|
||||||
emit finished(AccountTaskState::STATE_FAILED_HARD, tr("Failed to retrieve device authorization"));
|
emit finished(AccountTaskState::STATE_FAILED_HARD, tr("Failed to retrieve device authorization"));
|
||||||
qDebug() << *m_response;
|
qDebug() << *m_response;
|
||||||
return;
|
return;
|
||||||
@ -145,8 +148,8 @@ void MSADeviceCodeStep::abort()
|
|||||||
{
|
{
|
||||||
m_expiration_timer.stop();
|
m_expiration_timer.stop();
|
||||||
m_pool_timer.stop();
|
m_pool_timer.stop();
|
||||||
if (m_task) {
|
if (m_request) {
|
||||||
m_task->abort();
|
m_request->abort();
|
||||||
}
|
}
|
||||||
m_is_aborted = true;
|
m_is_aborted = true;
|
||||||
emit finished(AccountTaskState::STATE_FAILED_HARD, tr("Task aborted"));
|
emit finished(AccountTaskState::STATE_FAILED_HARD, tr("Task aborted"));
|
||||||
@ -179,13 +182,13 @@ void MSADeviceCodeStep::authenticateUser()
|
|||||||
{ "Accept", "application/json" },
|
{ "Accept", "application/json" },
|
||||||
};
|
};
|
||||||
m_response.reset(new QByteArray());
|
m_response.reset(new QByteArray());
|
||||||
m_task = Net::Upload::makeByteArray(url, m_response, payload);
|
m_request = Net::Upload::makeByteArray(url, m_response, payload);
|
||||||
m_task->addHeaderProxy(new Net::StaticHeaderProxy(headers));
|
m_request->addHeaderProxy(new Net::StaticHeaderProxy(headers));
|
||||||
|
|
||||||
connect(m_task.get(), &Task::finished, this, &MSADeviceCodeStep::authenticationFinished);
|
connect(m_request.get(), &Task::finished, this, &MSADeviceCodeStep::authenticationFinished);
|
||||||
|
|
||||||
m_task->setNetwork(APPLICATION->network());
|
m_request->setNetwork(APPLICATION->network());
|
||||||
m_task->start();
|
m_request->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AuthenticationResponse {
|
struct AuthenticationResponse {
|
||||||
@ -225,7 +228,7 @@ AuthenticationResponse parseAuthenticationResponse(const QByteArray& data)
|
|||||||
|
|
||||||
void MSADeviceCodeStep::authenticationFinished()
|
void MSADeviceCodeStep::authenticationFinished()
|
||||||
{
|
{
|
||||||
if (m_task->error() == QNetworkReply::TimeoutError) {
|
if (m_request->error() == QNetworkReply::TimeoutError) {
|
||||||
// rfc8628#section-3.5
|
// rfc8628#section-3.5
|
||||||
// "On encountering a connection timeout, clients MUST unilaterally
|
// "On encountering a connection timeout, clients MUST unilaterally
|
||||||
// reduce their polling frequency before retrying. The use of an
|
// reduce their polling frequency before retrying. The use of an
|
||||||
@ -258,7 +261,7 @@ void MSADeviceCodeStep::authenticationFinished()
|
|||||||
tr("Device Access failed: %1").arg(rsp.error_description.isEmpty() ? rsp.error : rsp.error_description));
|
tr("Device Access failed: %1").arg(rsp.error_description.isEmpty() ? rsp.error : rsp.error_description));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!m_task->wasSuccessful() || m_task->error() != QNetworkReply::NoError) {
|
if (!m_request->wasSuccessful() || m_request->error() != QNetworkReply::NoError) {
|
||||||
startPoolTimer(); // it failed so just try again without increasing the interval
|
startPoolTimer(); // it failed so just try again without increasing the interval
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include "minecraft/auth/AuthStep.h"
|
#include "minecraft/auth/AuthStep.h"
|
||||||
|
#include "net/NetJob.h"
|
||||||
#include "net/Upload.h"
|
#include "net/Upload.h"
|
||||||
|
|
||||||
class MSADeviceCodeStep : public AuthStep {
|
class MSADeviceCodeStep : public AuthStep {
|
||||||
@ -72,5 +73,6 @@ class MSADeviceCodeStep : public AuthStep {
|
|||||||
QTimer m_expiration_timer;
|
QTimer m_expiration_timer;
|
||||||
|
|
||||||
std::shared_ptr<QByteArray> m_response;
|
std::shared_ptr<QByteArray> m_response;
|
||||||
Net::Upload::Ptr m_task;
|
Net::Upload::Ptr m_request;
|
||||||
|
NetJob::Ptr m_task;
|
||||||
};
|
};
|
||||||
|
@ -22,37 +22,41 @@ void MinecraftProfileStep::perform()
|
|||||||
{ "Authorization", QString("Bearer %1").arg(m_data->yggdrasilToken.token).toUtf8() } };
|
{ "Authorization", QString("Bearer %1").arg(m_data->yggdrasilToken.token).toUtf8() } };
|
||||||
|
|
||||||
m_response.reset(new QByteArray());
|
m_response.reset(new QByteArray());
|
||||||
m_task = Net::Download::makeByteArray(url, m_response);
|
m_request = Net::Download::makeByteArray(url, m_response);
|
||||||
m_task->addHeaderProxy(new Net::StaticHeaderProxy(headers));
|
m_request->addHeaderProxy(new Net::StaticHeaderProxy(headers));
|
||||||
|
|
||||||
|
m_task.reset(new NetJob("MinecraftProfileStep", APPLICATION->network()));
|
||||||
|
m_task->setAskRetry(false);
|
||||||
|
m_task->addNetAction(m_request);
|
||||||
|
|
||||||
connect(m_task.get(), &Task::finished, this, &MinecraftProfileStep::onRequestDone);
|
connect(m_task.get(), &Task::finished, this, &MinecraftProfileStep::onRequestDone);
|
||||||
|
|
||||||
m_task->setNetwork(APPLICATION->network());
|
|
||||||
m_task->start();
|
m_task->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecraftProfileStep::onRequestDone()
|
void MinecraftProfileStep::onRequestDone()
|
||||||
{
|
{
|
||||||
if (m_task->error() == QNetworkReply::ContentNotFoundError) {
|
if (m_request->error() == QNetworkReply::ContentNotFoundError) {
|
||||||
// NOTE: Succeed even if we do not have a profile. This is a valid account state.
|
// NOTE: Succeed even if we do not have a profile. This is a valid account state.
|
||||||
m_data->minecraftProfile = MinecraftProfile();
|
m_data->minecraftProfile = MinecraftProfile();
|
||||||
emit finished(AccountTaskState::STATE_WORKING, tr("Account has no Minecraft profile."));
|
emit finished(AccountTaskState::STATE_WORKING, tr("Account has no Minecraft profile."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_task->error() != QNetworkReply::NoError) {
|
if (m_request->error() != QNetworkReply::NoError) {
|
||||||
qWarning() << "Error getting profile:";
|
qWarning() << "Error getting profile:";
|
||||||
qWarning() << " HTTP Status: " << m_task->replyStatusCode();
|
qWarning() << " HTTP Status: " << m_request->replyStatusCode();
|
||||||
qWarning() << " Internal error no.: " << m_task->error();
|
qWarning() << " Internal error no.: " << m_request->error();
|
||||||
qWarning() << " Error string: " << m_task->errorString();
|
qWarning() << " Error string: " << m_request->errorString();
|
||||||
|
|
||||||
qWarning() << " Response:";
|
qWarning() << " Response:";
|
||||||
qWarning() << QString::fromUtf8(*m_response);
|
qWarning() << QString::fromUtf8(*m_response);
|
||||||
|
|
||||||
if (Net::isApplicationError(m_task->error())) {
|
if (Net::isApplicationError(m_request->error())) {
|
||||||
emit finished(AccountTaskState::STATE_FAILED_SOFT,
|
emit finished(AccountTaskState::STATE_FAILED_SOFT,
|
||||||
tr("Minecraft Java profile acquisition failed: %1").arg(m_task->errorString()));
|
tr("Minecraft Java profile acquisition failed: %1").arg(m_request->errorString()));
|
||||||
} else {
|
} else {
|
||||||
emit finished(AccountTaskState::STATE_OFFLINE, tr("Minecraft Java profile acquisition failed: %1").arg(m_task->errorString()));
|
emit finished(AccountTaskState::STATE_OFFLINE,
|
||||||
|
tr("Minecraft Java profile acquisition failed: %1").arg(m_request->errorString()));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "minecraft/auth/AuthStep.h"
|
#include "minecraft/auth/AuthStep.h"
|
||||||
#include "net/Download.h"
|
#include "net/Download.h"
|
||||||
|
#include "net/NetJob.h"
|
||||||
|
|
||||||
class MinecraftProfileStep : public AuthStep {
|
class MinecraftProfileStep : public AuthStep {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -21,5 +22,6 @@ class MinecraftProfileStep : public AuthStep {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<QByteArray> m_response;
|
std::shared_ptr<QByteArray> m_response;
|
||||||
Net::Download::Ptr m_task;
|
Net::Download::Ptr m_request;
|
||||||
|
NetJob::Ptr m_task;
|
||||||
};
|
};
|
||||||
|
@ -42,12 +42,15 @@ void XboxAuthorizationStep::perform()
|
|||||||
{ "Accept", "application/json" },
|
{ "Accept", "application/json" },
|
||||||
};
|
};
|
||||||
m_response.reset(new QByteArray());
|
m_response.reset(new QByteArray());
|
||||||
m_task = Net::Upload::makeByteArray(url, m_response, xbox_auth_data.toUtf8());
|
m_request = Net::Upload::makeByteArray(url, m_response, xbox_auth_data.toUtf8());
|
||||||
m_task->addHeaderProxy(new Net::StaticHeaderProxy(headers));
|
m_request->addHeaderProxy(new Net::StaticHeaderProxy(headers));
|
||||||
|
|
||||||
|
m_task.reset(new NetJob("XboxAuthorizationStep", APPLICATION->network()));
|
||||||
|
m_task->setAskRetry(false);
|
||||||
|
m_task->addNetAction(m_request);
|
||||||
|
|
||||||
connect(m_task.get(), &Task::finished, this, &XboxAuthorizationStep::onRequestDone);
|
connect(m_task.get(), &Task::finished, this, &XboxAuthorizationStep::onRequestDone);
|
||||||
|
|
||||||
m_task->setNetwork(APPLICATION->network());
|
|
||||||
m_task->start();
|
m_task->start();
|
||||||
qDebug() << "Getting authorization token for " << m_relyingParty;
|
qDebug() << "Getting authorization token for " << m_relyingParty;
|
||||||
}
|
}
|
||||||
@ -55,19 +58,19 @@ void XboxAuthorizationStep::perform()
|
|||||||
void XboxAuthorizationStep::onRequestDone()
|
void XboxAuthorizationStep::onRequestDone()
|
||||||
{
|
{
|
||||||
qCDebug(authCredentials()) << *m_response;
|
qCDebug(authCredentials()) << *m_response;
|
||||||
if (m_task->error() != QNetworkReply::NoError) {
|
if (m_request->error() != QNetworkReply::NoError) {
|
||||||
qWarning() << "Reply error:" << m_task->error();
|
qWarning() << "Reply error:" << m_request->error();
|
||||||
if (Net::isApplicationError(m_task->error())) {
|
if (Net::isApplicationError(m_request->error())) {
|
||||||
if (!processSTSError()) {
|
if (!processSTSError()) {
|
||||||
emit finished(AccountTaskState::STATE_FAILED_SOFT,
|
emit finished(AccountTaskState::STATE_FAILED_SOFT,
|
||||||
tr("Failed to get authorization for %1 services. Error %2.").arg(m_authorizationKind, m_task->error()));
|
tr("Failed to get authorization for %1 services. Error %2.").arg(m_authorizationKind, m_request->error()));
|
||||||
} else {
|
} else {
|
||||||
emit finished(AccountTaskState::STATE_FAILED_SOFT,
|
emit finished(AccountTaskState::STATE_FAILED_SOFT,
|
||||||
tr("Unknown STS error for %1 services: %2").arg(m_authorizationKind, m_task->errorString()));
|
tr("Unknown STS error for %1 services: %2").arg(m_authorizationKind, m_request->errorString()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emit finished(AccountTaskState::STATE_OFFLINE,
|
emit finished(AccountTaskState::STATE_OFFLINE,
|
||||||
tr("Failed to get authorization for %1 services: %2").arg(m_authorizationKind, m_task->errorString()));
|
tr("Failed to get authorization for %1 services: %2").arg(m_authorizationKind, m_request->errorString()));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -92,7 +95,7 @@ void XboxAuthorizationStep::onRequestDone()
|
|||||||
|
|
||||||
bool XboxAuthorizationStep::processSTSError()
|
bool XboxAuthorizationStep::processSTSError()
|
||||||
{
|
{
|
||||||
if (m_task->error() == QNetworkReply::AuthenticationRequiredError) {
|
if (m_request->error() == QNetworkReply::AuthenticationRequiredError) {
|
||||||
QJsonParseError jsonError;
|
QJsonParseError jsonError;
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(*m_response, &jsonError);
|
QJsonDocument doc = QJsonDocument::fromJson(*m_response, &jsonError);
|
||||||
if (jsonError.error) {
|
if (jsonError.error) {
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "minecraft/auth/AuthStep.h"
|
#include "minecraft/auth/AuthStep.h"
|
||||||
|
#include "net/NetJob.h"
|
||||||
#include "net/Upload.h"
|
#include "net/Upload.h"
|
||||||
|
|
||||||
class XboxAuthorizationStep : public AuthStep {
|
class XboxAuthorizationStep : public AuthStep {
|
||||||
@ -28,5 +29,6 @@ class XboxAuthorizationStep : public AuthStep {
|
|||||||
QString m_authorizationKind;
|
QString m_authorizationKind;
|
||||||
|
|
||||||
std::shared_ptr<QByteArray> m_response;
|
std::shared_ptr<QByteArray> m_response;
|
||||||
Net::Upload::Ptr m_task;
|
Net::Upload::Ptr m_request;
|
||||||
|
NetJob::Ptr m_task;
|
||||||
};
|
};
|
||||||
|
@ -34,25 +34,28 @@ void XboxProfileStep::perform()
|
|||||||
};
|
};
|
||||||
|
|
||||||
m_response.reset(new QByteArray());
|
m_response.reset(new QByteArray());
|
||||||
m_task = Net::Download::makeByteArray(url, m_response);
|
m_request = Net::Download::makeByteArray(url, m_response);
|
||||||
m_task->addHeaderProxy(new Net::StaticHeaderProxy(headers));
|
m_request->addHeaderProxy(new Net::StaticHeaderProxy(headers));
|
||||||
|
|
||||||
|
m_task.reset(new NetJob("XboxProfileStep", APPLICATION->network()));
|
||||||
|
m_task->setAskRetry(false);
|
||||||
|
m_task->addNetAction(m_request);
|
||||||
|
|
||||||
connect(m_task.get(), &Task::finished, this, &XboxProfileStep::onRequestDone);
|
connect(m_task.get(), &Task::finished, this, &XboxProfileStep::onRequestDone);
|
||||||
|
|
||||||
m_task->setNetwork(APPLICATION->network());
|
|
||||||
m_task->start();
|
m_task->start();
|
||||||
qDebug() << "Getting Xbox profile...";
|
qDebug() << "Getting Xbox profile...";
|
||||||
}
|
}
|
||||||
|
|
||||||
void XboxProfileStep::onRequestDone()
|
void XboxProfileStep::onRequestDone()
|
||||||
{
|
{
|
||||||
if (m_task->error() != QNetworkReply::NoError) {
|
if (m_request->error() != QNetworkReply::NoError) {
|
||||||
qWarning() << "Reply error:" << m_task->error();
|
qWarning() << "Reply error:" << m_request->error();
|
||||||
qCDebug(authCredentials()) << *m_response;
|
qCDebug(authCredentials()) << *m_response;
|
||||||
if (Net::isApplicationError(m_task->error())) {
|
if (Net::isApplicationError(m_request->error())) {
|
||||||
emit finished(AccountTaskState::STATE_FAILED_SOFT, tr("Failed to retrieve the Xbox profile: %1").arg(m_task->errorString()));
|
emit finished(AccountTaskState::STATE_FAILED_SOFT, tr("Failed to retrieve the Xbox profile: %1").arg(m_request->errorString()));
|
||||||
} else {
|
} else {
|
||||||
emit finished(AccountTaskState::STATE_OFFLINE, tr("Failed to retrieve the Xbox profile: %1").arg(m_task->errorString()));
|
emit finished(AccountTaskState::STATE_OFFLINE, tr("Failed to retrieve the Xbox profile: %1").arg(m_request->errorString()));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "minecraft/auth/AuthStep.h"
|
#include "minecraft/auth/AuthStep.h"
|
||||||
#include "net/Download.h"
|
#include "net/Download.h"
|
||||||
|
#include "net/NetJob.h"
|
||||||
|
|
||||||
class XboxProfileStep : public AuthStep {
|
class XboxProfileStep : public AuthStep {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -21,5 +22,6 @@ class XboxProfileStep : public AuthStep {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<QByteArray> m_response;
|
std::shared_ptr<QByteArray> m_response;
|
||||||
Net::Download::Ptr m_task;
|
Net::Download::Ptr m_request;
|
||||||
|
NetJob::Ptr m_task;
|
||||||
};
|
};
|
||||||
|
@ -38,24 +38,27 @@ void XboxUserStep::perform()
|
|||||||
{ "x-xbl-contract-version", "1" }
|
{ "x-xbl-contract-version", "1" }
|
||||||
};
|
};
|
||||||
m_response.reset(new QByteArray());
|
m_response.reset(new QByteArray());
|
||||||
m_task = Net::Upload::makeByteArray(url, m_response, xbox_auth_data.toUtf8());
|
m_request = Net::Upload::makeByteArray(url, m_response, xbox_auth_data.toUtf8());
|
||||||
m_task->addHeaderProxy(new Net::StaticHeaderProxy(headers));
|
m_request->addHeaderProxy(new Net::StaticHeaderProxy(headers));
|
||||||
|
|
||||||
|
m_task.reset(new NetJob("XboxUserStep", APPLICATION->network()));
|
||||||
|
m_task->setAskRetry(false);
|
||||||
|
m_task->addNetAction(m_request);
|
||||||
|
|
||||||
connect(m_task.get(), &Task::finished, this, &XboxUserStep::onRequestDone);
|
connect(m_task.get(), &Task::finished, this, &XboxUserStep::onRequestDone);
|
||||||
|
|
||||||
m_task->setNetwork(APPLICATION->network());
|
|
||||||
m_task->start();
|
m_task->start();
|
||||||
qDebug() << "First layer of XBox auth ... commencing.";
|
qDebug() << "First layer of XBox auth ... commencing.";
|
||||||
}
|
}
|
||||||
|
|
||||||
void XboxUserStep::onRequestDone()
|
void XboxUserStep::onRequestDone()
|
||||||
{
|
{
|
||||||
if (m_task->error() != QNetworkReply::NoError) {
|
if (m_request->error() != QNetworkReply::NoError) {
|
||||||
qWarning() << "Reply error:" << m_task->error();
|
qWarning() << "Reply error:" << m_request->error();
|
||||||
if (Net::isApplicationError(m_task->error())) {
|
if (Net::isApplicationError(m_request->error())) {
|
||||||
emit finished(AccountTaskState::STATE_FAILED_SOFT, tr("XBox user authentication failed: %1").arg(m_task->errorString()));
|
emit finished(AccountTaskState::STATE_FAILED_SOFT, tr("XBox user authentication failed: %1").arg(m_request->errorString()));
|
||||||
} else {
|
} else {
|
||||||
emit finished(AccountTaskState::STATE_OFFLINE, tr("XBox user authentication failed: %1").arg(m_task->errorString()));
|
emit finished(AccountTaskState::STATE_OFFLINE, tr("XBox user authentication failed: %1").arg(m_request->errorString()));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "minecraft/auth/AuthStep.h"
|
#include "minecraft/auth/AuthStep.h"
|
||||||
|
#include "net/NetJob.h"
|
||||||
#include "net/Upload.h"
|
#include "net/Upload.h"
|
||||||
|
|
||||||
class XboxUserStep : public AuthStep {
|
class XboxUserStep : public AuthStep {
|
||||||
@ -21,5 +22,6 @@ class XboxUserStep : public AuthStep {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<QByteArray> m_response;
|
std::shared_ptr<QByteArray> m_response;
|
||||||
Net::Upload::Ptr m_task;
|
Net::Upload::Ptr m_request;
|
||||||
|
NetJob::Ptr m_task;
|
||||||
};
|
};
|
||||||
|
@ -172,4 +172,4 @@ void NetJob::emitFailed(QString reason)
|
|||||||
void NetJob::setAskRetry(bool askRetry)
|
void NetJob::setAskRetry(bool askRetry)
|
||||||
{
|
{
|
||||||
m_ask_retry = askRetry;
|
m_ask_retry = askRetry;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user