import React from 'react' import { type Meta } from '@storybook/react-vite' import { DocsTemplate } from '../../../.storybook' export const Example = (): React.JSX.Element => { return (
exchangeGlobalToken is an async helper function that exchanges an Auth0 id token with the adminczar global token exchange endpoint.
This function allows all frontend applications to reuse the same global token exchange logic without redirecting users to the Admin frontend application.
Note: This function makes an API call and cannot be demonstrated interactively in Storybook.
idToken (required): The Auth0 id token to
exchange
options (optional): Configuration object with:
headers: Additional headers to include in
the request
apiBaseUrl: Custom API base URL (defaults
to adminczar API prefix)
success: Boolean indicating if the exchange was
successful
userProfile: All JWT claims decoded from the
access token (sub, exp, iat, email, name, etc.)
idToken: id token
expiresAt: Token expiration time in
milliseconds since epoch
error: Error type if failed
('invalid_token', 'unauthorized',
'exchange_failed', 'exchange_error')
status: HTTP status code if available
invalid_token: The provided idToken is not a
valid JWT
unauthorized: API returned 401 status
exchange_failed: API returned non-200 status,
or access_token missing/invalid in response
exchange_error: Network or other error occurred