fix: improve error handling and logging in OIDC token exchange and redirect callback
This commit is contained in:
@@ -166,12 +166,16 @@ async function handleRedirectCallback(): Promise<string | null> {
|
||||
|
||||
const result = await response.json()
|
||||
const token = result.access_token || result.id_token
|
||||
if (response.ok && token) {
|
||||
setLocalToken(token)
|
||||
return token
|
||||
console.debug('OIDC callback result:', result)
|
||||
if (!response.ok) {
|
||||
throw new Error(result.error_description || 'OIDC callback failed')
|
||||
}
|
||||
if (!token) {
|
||||
throw new Error('OIDC callback did not return an access token')
|
||||
}
|
||||
|
||||
throw new Error(result.error_description || 'OIDC callback failed')
|
||||
setLocalToken(token)
|
||||
return token
|
||||
}
|
||||
|
||||
function App() {
|
||||
@@ -207,6 +211,7 @@ function App() {
|
||||
)
|
||||
|
||||
async function login() {
|
||||
clearLocalToken()
|
||||
try {
|
||||
const config = await fetchOIDCConfig()
|
||||
const state = generateUUID()
|
||||
|
||||
Reference in New Issue
Block a user