Add refresh token handling if returned from server

This commit is contained in:
Allen Zhou
2025-02-03 19:53:53 -08:00
parent d438760e36
commit 79547143a8
4 changed files with 74 additions and 8 deletions

View File

@@ -24,9 +24,12 @@ const OAuthCallback = () => {
}
try {
const accessToken = await handleOAuthCallback(serverUrl, code);
// Store the access token for future use
sessionStorage.setItem(SESSION_KEYS.ACCESS_TOKEN, accessToken);
const tokens = await handleOAuthCallback(serverUrl, code);
// Store both access and refresh tokens
sessionStorage.setItem(SESSION_KEYS.ACCESS_TOKEN, tokens.access_token);
if (tokens.refresh_token) {
sessionStorage.setItem(SESSION_KEYS.REFRESH_TOKEN, tokens.refresh_token);
}
// Redirect back to the main app with server URL to trigger auto-connect
window.location.href = `/?serverUrl=${encodeURIComponent(serverUrl)}`;
} catch (error) {