feat(web): add client utilities

This commit is contained in:
dahyeon committed 2026-04-10 23:39:00 +09:00
1 parent a796620b7f
commit 39f3221640
7 files changed
+335

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
import {
isMsalConfigured,
MSAL_API_SCOPE,
MSAL_SILENT_REDIRECT_URI,
msalInstance,
} from './msal.config';
export async function acquireAccessToken(): Promise<string | null> {
if (!isMsalConfigured || !msalInstance) {
return null;
}
const accounts = msalInstance.getAllAccounts();
const account = msalInstance.getActiveAccount() ?? accounts[0];
if (!account) {
return null;
}
const response = await msalInstance.acquireTokenSilent({
account,
scopes: [MSAL_API_SCOPE],
redirectUri: MSAL_SILENT_REDIRECT_URI,
});
return response.accessToken;
}