Skip to content

Commit

Permalink
fix: Game Data app + lc editing
Browse files Browse the repository at this point in the history
fix: Use more Oauth2 Complaint FPFSS
  • Loading branch information
colin969 committed Nov 16, 2023
1 parent 1b949a4 commit cdbfef6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/back/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,8 @@ export function registerRequestCallbacks(state: BackState, init: () => Promise<v
const existingData = await GameDataManager.findOne(d.id);
if (existingData) {
existingData.title = d.title;
existingData.applicationPath = d.applicationPath;
existingData.launchCommand = d.launchCommand;
existingData.parameters = d.parameters;
return GameDataManager.save(existingData);
}
Expand Down
26 changes: 22 additions & 4 deletions src/renderer/fpfss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,28 @@ export async function fpfssLogin(dispatchMain: Dispatch<MainAction>, 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,
Expand All @@ -39,9 +48,18 @@ export async function fpfssLogin(dispatchMain: Dispatch<MainAction>, dialogResEv

// Start loop until an end state occurs
return new Promise<FpfssUser | null>((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
Expand Down

0 comments on commit cdbfef6

Please sign in to comment.