Skip to content

Commit 35eab58

Browse files
committed
switch to metadata from state
1 parent 20e961c commit 35eab58

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

client/src/components/AuthDebugger.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useCallback, useMemo } from "react";
1+
import { useCallback, useMemo, useEffect } from "react";
22
import { Button } from "@/components/ui/button";
33
import { DebugInspectorOAuthClientProvider } from "../lib/auth";
44
import { AlertCircle } from "lucide-react";
@@ -60,6 +60,23 @@ const AuthDebugger = ({
6060
authState,
6161
updateAuthState,
6262
}: AuthDebuggerProps) => {
63+
// Initialize loading state
64+
useEffect(() => {
65+
if (authState.loading && serverUrl) {
66+
// Check if we have existing tokens
67+
const checkTokens = async () => {
68+
const provider = new DebugInspectorOAuthClientProvider(serverUrl);
69+
const existingTokens = await provider.tokens();
70+
71+
updateAuthState({
72+
loading: false,
73+
oauthTokens: existingTokens || null,
74+
});
75+
};
76+
77+
checkTokens();
78+
}
79+
}, [serverUrl, authState.loading, updateAuthState]);
6380
const startOAuthFlow = useCallback(() => {
6481
if (!serverUrl) {
6582
updateAuthState({

client/src/components/OAuthFlowProgress.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export const OAuthFlowProgress = ({
128128
label="Metadata Discovery"
129129
{...getStepProps("metadata_discovery")}
130130
>
131-
{provider.getServerMetadata() && (
131+
{authState.oauthMetadata && (
132132
<details className="text-xs mt-2">
133133
<summary className="cursor-pointer text-muted-foreground font-medium">
134134
OAuth Metadata Sources
@@ -165,14 +165,14 @@ export const OAuthFlowProgress = ({
165165
</div>
166166
)}
167167

168-
{provider.getServerMetadata() && (
168+
{authState.oauthMetadata && (
169169
<div className="mt-2">
170170
<p className="font-medium">Authorization Server Metadata:</p>
171171
{authState.authServerUrl && <p className="text-xs text-muted-foreground">
172172
From {new URL('/.well-known/oauth-authorization-server', authState.authServerUrl).href}
173173
</p>}
174174
<pre className="mt-2 p-2 bg-muted rounded-md overflow-auto max-h-[300px]">
175-
{JSON.stringify(provider.getServerMetadata(), null, 2)}
175+
{JSON.stringify(authState.oauthMetadata, null, 2)}
176176
</pre>
177177
</div>
178178
)}

0 commit comments

Comments
 (0)