Smart Repair: Check all token locations including .qwen-tokens.json
This commit is contained in:
@@ -73,20 +73,28 @@ const banner = () => {
|
|||||||
console.log('');
|
console.log('');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get Qwen auth token
|
// Get Qwen auth token - checks multiple locations
|
||||||
const getAuthToken = () => {
|
const getAuthToken = () => {
|
||||||
try {
|
// Multiple paths where tokens might be stored
|
||||||
if (fs.existsSync(TOKENS_FILE)) {
|
const tokenPaths = [
|
||||||
const tokens = JSON.parse(fs.readFileSync(TOKENS_FILE, 'utf8'));
|
path.join(ROOT, '.qwen-tokens.json'), // QwenOAuth default
|
||||||
return tokens.access_token || null;
|
path.join(ROOT, 'tokens.json'), // Alternative location
|
||||||
}
|
path.join(process.env.HOME || process.env.USERPROFILE || '', '.qwen', 'config.json'), // qwen CLI
|
||||||
// Try qwen CLI config
|
path.join(process.env.HOME || process.env.USERPROFILE || '', '.qwen', 'tokens.json'),
|
||||||
const configPath = path.join(process.env.HOME || process.env.USERPROFILE, '.qwen', 'config.json');
|
];
|
||||||
if (fs.existsSync(configPath)) {
|
|
||||||
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
for (const tokenPath of tokenPaths) {
|
||||||
return config.access_token || config.api_key || null;
|
try {
|
||||||
}
|
if (fs.existsSync(tokenPath)) {
|
||||||
} catch (e) { /* ignore */ }
|
const tokens = JSON.parse(fs.readFileSync(tokenPath, 'utf8'));
|
||||||
|
const token = tokens.access_token || tokens.api_key || tokens.token;
|
||||||
|
if (token) {
|
||||||
|
console.log(C.dim + ` [Found token in ${path.basename(tokenPath)}]` + C.reset);
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) { /* ignore */ }
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user