MCPcopy Create free account
hub / github.com/Roy3838/Observer / Auth0Debug

Function Auth0Debug

app/src/components/debug/Auth0Debug.tsx:4–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2import { useAuth0 } from '@auth0/auth0-react';
3
4export const Auth0Debug = () => {
5 const {
6 isLoading,
7 isAuthenticated,
8 error,
9 user,
10 getAccessTokenSilently,
11 } = useAuth0();
12
13 const [token, setToken] = React.useState<string | null>(null);
14 const [tokenError, setTokenError] = React.useState<string | null>(null);
15
16 const fetchToken = async () => {
17 try {
18 const accessToken = await getAccessTokenSilently();
19 setToken(accessToken ?? null);
20 setTokenError(null);
21 } catch (err) {
22 setToken(null);
23 setTokenError(err instanceof Error ? err.message : String(err));
24 }
25 };
26
27 return (
28 <div className="fixed top-20 right-4 p-4 bg-white shadow-lg rounded-md z-50 max-w-md overflow-auto max-h-[80vh]">
29 <h2 className="text-lg font-bold mb-2 border-b pb-2">Auth0 Debug Info</h2>
30
31 <div className="space-y-2 mb-4">
32 <div><span className="font-medium">Loading:</span> {isLoading ? 'true' : 'false'}</div>
33 <div><span className="font-medium">Authenticated:</span> {isAuthenticated ? 'true' : 'false'}</div>
34 {error && (
35 <div className="text-red-600">
36 <span className="font-medium">Error:</span> {error.message}
37 </div>
38 )}
39 </div>
40
41 {user && (
42 <div className="mb-4">
43 <h3 className="font-medium mb-1">User Info:</h3>
44 <pre className="bg-gray-100 p-2 rounded text-xs overflow-x-auto">
45 {JSON.stringify(user, null, 2)}
46 </pre>
47 </div>
48 )}
49
50 <div className="mb-3">
51 <button
52 onClick={fetchToken}
53 className="px-3 py-1 bg-blue-500 text-white rounded hover:bg-blue-600"
54 disabled={!isAuthenticated}
55 >
56 Test Get Token
57 </button>
58 </div>
59
60 {token && (
61 <div className="mb-4">

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected