Please include the following information in your post:
- Which SDK this is regarding: @auth0/auth0-react
- SDK Version: 1.0.3
- Platform Version: Node v15.11.0,
- Code Snippets/Error Messages/Supporting Details/Screenshots:
The authentication is part of storybook add-on.
<QueryClientProvider client={queryClient}>
<Auth0Provider
domain={process.env.STORYBOOK_AUTH0_ISSUER_BASE_URL}
clientId={process.env.STORYBOOK_AUTH0_CLIENT_ID}
redirectUri={window.location.origin}
>
<Auth />
</Auth0Provider>
</QueryClientProvider>
Auth.js
import React, {useEffect, useRef} from ‘react’
import { useAuth0 } from ‘@auth0/auth0-react’;
const Auth = () => {
const { isAuthenticated, loginWithRedirect, logout } = useAuth0();
console.log(isAuthenticated);
return isAuthenticated ? (
<button
href=“#”
color=“primary”
variant=“outlined”
onClick={() => logout({ ‘returnTo’: window.location.origin })}
>
Logout
) : (
<button
href=“#”
color=“primary”
variant=“outlined”
onClick={() => loginWithRedirect()}
>
Login
);
};
There is an existing issue isAuthenticated is false after successful login · Issue #82 · auth0/auth0-react · GitHub though closed not sure if anyone else is also facing same.