MCPcopy Create free account
hub / github.com/MultiMC/Launcher / onRequestDone

Method onRequestDone

launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp:52–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52void XboxAuthorizationStep::onRequestDone(
53 QNetworkReply::NetworkError error,
54 QByteArray data,
55 QList<QNetworkReply::RawHeaderPair> headers
56) {
57 auto requestor = qobject_cast<AuthRequest *>(QObject::sender());
58 requestor->deleteLater();
59
60#ifndef NDEBUG
61 qDebug() << data;
62#endif
63 if (error != QNetworkReply::NoError) {
64 qWarning() << "Reply error:" << error;
65 if(!processSTSError(error, data, headers)) {
66 emit finished(
67 AccountTaskState::STATE_FAILED_SOFT,
68 tr("Failed to get authorization for %1 services. Error %2.").arg(m_authorizationKind, error)
69 );
70 }
71 return;
72 }
73
74 Katabasis::Token temp;
75 if(!Parsers::parseXTokenResponse(data, temp, m_authorizationKind)) {
76 emit finished(
77 AccountTaskState::STATE_FAILED_SOFT,
78 tr("Could not parse authorization response for access to %1 services.").arg(m_authorizationKind)
79 );
80 return;
81 }
82
83 if(temp.extra["uhs"] != m_data->userToken.extra["uhs"]) {
84 emit finished(
85 AccountTaskState::STATE_FAILED_SOFT,
86 tr("Server has changed %1 authorization user hash in the reply. Something is wrong.").arg(m_authorizationKind)
87 );
88 return;
89 }
90 auto & token = *m_token;
91 token = temp;
92
93 emit finished(AccountTaskState::STATE_WORKING, tr("Got authorization to access %1").arg(m_relyingParty));
94}
95
96
97bool XboxAuthorizationStep::processSTSError(

Callers

nothing calls this directly

Calls 1

parseXTokenResponseFunction · 0.85

Tested by

no test coverage detected