Skip to content

Commit

Permalink
Merge pull request #255 from csfloat/fix/refresh-steam-jwt
Browse files Browse the repository at this point in the history
Fixes Refreshing Steam JWT Upon Fetch
  • Loading branch information
Step7750 authored Sep 23, 2024
2 parents 691623f + e4066ae commit f40190c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/lib/alarms/access_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export async function getAccessToken(expectedSteamID?: string): Promise<AccessTo
// Need to fetch a new one
const resp = await fetch(`https://steamcommunity.com`, {
credentials: 'include',
headers: {
// Required for Steam to refresh the JWT when it expires
Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9;q=0.8,application/signed-exchange;v=b3;q=0.7',
},
});

const body = await resp.text();
Expand Down
7 changes: 6 additions & 1 deletion src/lib/bridge/handlers/fetch_steam_user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ interface FetchSteamUserResponse {
export const FetchSteamUser = new SimpleHandler<FetchSteamUserRequest, FetchSteamUserResponse>(
RequestType.FETCH_STEAM_USER,
async (req) => {
const resp = await fetch('https://steamcommunity.com');
const resp = await fetch('https://steamcommunity.com', {
headers: {
// Required for Steam to refresh the JWT when it expires
Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9;q=0.8,application/signed-exchange;v=b3;q=0.7',
},
});
if (!resp.ok) {
throw new Error('non-ok response for steamcommunity.com');
}
Expand Down

0 comments on commit f40190c

Please sign in to comment.