<AsgardeoCallback />
<AsgardeoCallback> is a headless component of the WSO2 Identity Server Nuxt SDK (@asgardeo/nuxt) that forwards OAuth callback parameters to the route that started an OAuth redirect.
Overview¶
You don't need <AsgardeoCallback> for the standard redirect sign-in flow. The module's /api/auth/callback server route handles that callback, sets the session cookie, and redirects the user.
<AsgardeoCallback> is for client-side flows that store their originating route in sessionStorage under the key asgardeo_oauth_<state> before they redirect to an identity provider. When it mounts in the browser, the component:
- Reads
code,state,nonce,error, anderror_descriptionfrom the URL. If none ofcode,state, orerroris present, it does nothing. - Looks up the stored entry for
stateand checks that it's no older than five minutes. It then removes the entry. - Navigates to the stored path with
code(andnonce, if present) as query parameters. If the provider returned an error, it navigates witherroranderror_descriptioninstead.
If validation fails, the component calls onError and navigates to the stored path, or to /, with error=callback_error and an error_description.
The component renders nothing.
Usage¶
The component is auto-registered, so you don't need to import it.
<script setup lang="ts">
const onError = (error: Error) => {
console.error('OAuth callback failed:', error);
};
</script>
<template>
<AsgardeoCallback :on-error="onError" />
</template>
Props¶
| Prop | Type | Required | Description |
|---|---|---|---|
onError |
(error: Error) => void |
No | Called when the callback contains an error or fails validation. |
onNavigate |
(path: string) => void |
No | Replaces the default navigation, which uses Nuxt's navigateTo(). |