Skip to content

Instantly share code, notes, and snippets.

@ThisNils
Last active April 10, 2020 09:23
Show Gist options
  • Save ThisNils/cb4b97360ac75ea5c7da126df51480b5 to your computer and use it in GitHub Desktop.
Save ThisNils/cb4b97360ac75ea5c7da126df51480b5 to your computer and use it in GitHub Desktop.
const { Launcher } = require('epicgames-client');
const request = require('request-promise');
const deviceAuthCredentials = {
accountId: '',
deviceId: '',
secret: '',
};
/*
This is an example on how to launch epicgames-client using device auth.
Device auth prevents captcha errors. Just put in your device auth credentials in here.
To generate device auth credentials you can use my gist: https://gist.github.com/ThisNils/23c5dc9a49164e5419219a1654c0827c
*/
(async () => {
const launcher = new Launcher();
if (!await launcher.init()) {
throw new Error('Error while initialize process.');
}
const fortniteToken = await request.post({
url: 'https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/token',
form: {
grant_type: 'device_auth',
account_id: deviceAuthCredentials.accountId,
device_id: deviceAuthCredentials.deviceId,
secret: deviceAuthCredentials.secret,
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Authorization: 'basic MzQ0NmNkNzI2OTRjNGE0NDg1ZDgxYjc3YWRiYjIxNDE6OTIwOWQ0YTVlMjVhNDU3ZmI5YjA3NDg5ZDMxM2I0MWE=',
},
json: true,
});
const launcherExchange = await request.get({
url: 'https://account-public-service-prod.ol.epicgames.com/account/api/oauth/exchange',
headers: {
Authorization: `${fortniteToken.token_type} ${fortniteToken.access_token}`,
},
json: true,
});
await launcher.login(null, launcherExchange.code);
const playerName = 'Kysune';
const account = await launcher.getProfile(playerName);
if (!account) throw new Error(`Player ${playerName} not found!`);
console.log(`${account.name}'s id: ${account.id}`);
// "Kysune's id: 9a1d43b1d826420e9fa393a79b74b2ff"
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment