refactor(auth): replace client credentials with Basic auth and normalize response fields
This commit is contained in:
parent
d4acc813bc
commit
52bd469976
1 changed files with 7 additions and 3 deletions
|
|
@ -50,12 +50,11 @@ const pollForTokens = async (deviceCode, maxAttempts = 30) => {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
params.append('grant_type', 'urn:ietf:params:oauth:grant-type:device_code');
|
params.append('grant_type', 'urn:ietf:params:oauth:grant-type:device_code');
|
||||||
params.append('device_code', deviceCode);
|
params.append('device_code', deviceCode);
|
||||||
params.append('client_id', '98f7e42c2e3a4f86a74eb43fbb41ed39');
|
|
||||||
params.append('client_secret', '0a2449a2-001a-451e-afec-3e812901c4d7');
|
|
||||||
|
|
||||||
const response = await axios.post('https://account-public-service-prod.ol.epicgames.com/account/api/oauth/token', params.toString(), {
|
const response = await axios.post('https://account-public-service-prod.ol.epicgames.com/account/api/oauth/token', params.toString(), {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
'Authorization': 'Basic OThmN2U0MmMyZTNhNGY4NmE3NGViNDNmYmI0MWVkMzk6MGEyNDQ5YTItMDEwYS00NTFlLWFmZWMtM2U4MTI5MDFjNGQ3',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (response.data?.access_token) {
|
if (response.data?.access_token) {
|
||||||
|
|
@ -123,7 +122,12 @@ const getDeviceAuthorizationCode = async (clientCredentialsToken) => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
console.log('Device authorization response:', response.data);
|
console.log('Device authorization response:', response.data);
|
||||||
return response.data;
|
// Return the correct field names (device_code vs deviceCode)
|
||||||
|
return {
|
||||||
|
deviceCode: response.data.device_code,
|
||||||
|
userCode: response.data.user_code,
|
||||||
|
verificationUriComplete: response.data.verification_uri_complete
|
||||||
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to get device authorization code:', error.response?.status || error.message);
|
console.error('Failed to get device authorization code:', error.response?.status || error.message);
|
||||||
console.error('Error response data:', error.response?.data);
|
console.error('Error response data:', error.response?.data);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue