diff --git a/src/back/responses.ts b/src/back/responses.ts index c6b15edd0..4a4e1f636 100644 --- a/src/back/responses.ts +++ b/src/back/responses.ts @@ -868,6 +868,8 @@ export function registerRequestCallbacks(state: BackState, init: () => Promise, dialogResEv const fpfssBaseUrl = window.Shared.preferences.data.fpfssBaseUrl; // Get device auth token from FPFSS const tokenUrl = `${fpfssBaseUrl}/auth/token`; - const res = await axios.get(tokenUrl); + const data = { + 'client_id': 'flashpoint-launcher', + 'scope': 'identity game:read game:edit', + }; + const formData = new URLSearchParams(data).toString(); + const res = await axios.post(tokenUrl, formData, { + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + } + }); const token = { 'device_code': res.data['device_code'], 'user_code': res.data['user_code'], 'verification_uri': res.data['verification_uri'], + 'verification_uri_complete': res.data['verification_uri_complete'], 'expires_in': res.data['verification_uri'], 'interval': res.data['interval'] }; - const verifyUrl = `${token.verification_uri}?code=${token.user_code}`; const pollUrl = `${fpfssBaseUrl}/auth/token?device_code=${token.device_code}`; const profileUrl = `${fpfssBaseUrl}/api/profile`; - await remote.shell.openExternal(verifyUrl); + await remote.shell.openExternal(token.verification_uri_complete); const dialog: DialogState = { largeMessage: true, @@ -39,9 +48,18 @@ export async function fpfssLogin(dispatchMain: Dispatch, dialogResEv // Start loop until an end state occurs return new Promise((resolve, reject) => { + const pollData = { + 'device_code': token.device_code, + 'client_id': 'flashpoint-launcher' + }; + const formData = new URLSearchParams(pollData).toString(); const interval = setInterval(async () => { // Poll server for flow state - await axios.post(pollUrl) + await axios.post(pollUrl, formData, { + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + } + }) .then(async (res) => { if (res.data['access_token']) { // Found token, fetch profile info