fixed request for reauth on clicking show folder

This commit is contained in:
2026-01-10 19:39:57 +00:00
parent c22ada9c7e
commit 221e9d1f53
4 changed files with 44 additions and 35 deletions
+26
View File
@@ -58,9 +58,35 @@
errorEl.classList.add('hidden');
try {
// Step 1: Authenticate with PocketBase via Microsoft OAuth
const authData = await pb.collection('users').authWithOAuth2({
provider: 'microsoft',
});
// Step 2: Try to get Graph token from PB response
let graphToken = (
authData?.meta?.graphAccessToken ||
authData?.meta?.graph_token ||
authData?.meta?.graphToken ||
authData?.meta?.accessToken ||
authData?.meta?.access_token ||
authData?.meta?.token ||
''
);
// Step 3: If no Graph token from PB, use the OAuth token as the Graph token
// (PB's Microsoft OAuth should return a token that works with Graph API)
if (!graphToken && authData?.meta?.rawUser) {
// The OAuth token from Microsoft should work for Graph API calls
graphToken = authData?.token || authData?.meta?.accessToken || '';
}
if (graphToken) {
const expiresAt = authData?.meta?.graphTokenExpiresAt || new Date(Date.now() + 3600000).toISOString();
await tokenManager.setToken(graphToken, expiresAt);
console.log('[Login] Graph token stored successfully');
}
displayUserInfo(authData);
} catch (error) {
console.error('Login failed:', error);