fix: fall back to manual login when epic device code api fails
This commit is contained in:
parent
051363ed5f
commit
5c7a945be0
2 changed files with 17 additions and 6 deletions
|
|
@ -80,10 +80,16 @@ const getValidAuth = async ({ otpKey, reuseCookies, cookiesPath }) => {
|
|||
}
|
||||
|
||||
console.log('🔐 Starting fresh OAuth device flow (manual approval required)...');
|
||||
const deviceResponse = await axios.post('https://api.epicgames.dev/epic/oauth/deviceCode', {
|
||||
client_id: '34a02cf8f4414e29b159cdd02e6184bd',
|
||||
scope: 'account.basicprofile account.userentitlements',
|
||||
});
|
||||
let deviceResponse;
|
||||
try {
|
||||
deviceResponse = await axios.post('https://api.epicgames.dev/epic/oauth/deviceCode', {
|
||||
client_id: '34a02cf8f4414e29b159cdd02e6184bd',
|
||||
scope: 'account.basicprofile account.userentitlements',
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Device code flow failed (fallback to manual login):', e.response?.status || e.message);
|
||||
return { bearerToken: null, cookies: [] };
|
||||
}
|
||||
const { device_code, user_code, verification_uri_complete } = deviceResponse.data;
|
||||
console.log(`📱 Open: ${verification_uri_complete}`);
|
||||
console.log(`💳 Code: ${user_code}`);
|
||||
|
|
@ -258,8 +264,12 @@ export const claimEpicGamesNew = async () => {
|
|||
cookiesPath: COOKIES_PATH,
|
||||
});
|
||||
|
||||
await context.addCookies(auth.cookies);
|
||||
console.log('✅ Cookies loaded:', auth.cookies.length);
|
||||
if (auth.cookies?.length) {
|
||||
await context.addCookies(auth.cookies);
|
||||
console.log('✅ Cookies loaded:', auth.cookies.length);
|
||||
} else {
|
||||
console.log('⚠️ No cookies loaded; using manual login via browser.');
|
||||
}
|
||||
|
||||
await page.goto(URL_CLAIM, { waitUntil: 'domcontentloaded' });
|
||||
user = await ensureLoggedIn(page, context);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue