-
Notifications
You must be signed in to change notification settings - Fork 0
/
authcode.js
31 lines (25 loc) · 981 Bytes
/
authcode.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const { request } = require('undici');
const fs = require('fs');
const auth_code = '';
(async() => {
const response = await request('https://account-public-service-prod.ol.epicgames.com/account/api/oauth/token', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'basic ZWM2ODRiOGM2ODdmNDc5ZmFkZWEzY2IyYWQ4M2Y1YzY6ZTFmMzFjMjExZjI4NDEzMTg2MjYyZDM3YTEzZmM4NGQ=',
},
body: new URLSearchParams({
grant_type: 'authorization_code',
code: auth_code,
}).toString()
})
const data = await response.body.json()
console.log(data)
if(!data?.access_token) {
console.log('Failed to get access token.')
return
}
const current_auths = JSON.parse(fs.readFileSync('./device_auths.json', 'utf-8'))
current_auths.push(data)
fs.writeFileSync('./device_auths.json', JSON.stringify(current_auths, null, 4))
})()