Skip to content

Commit 70b965f

Browse files
committed
use proper scope handling
1 parent bf4b810 commit 70b965f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

client/src/components/AuthDebugger.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,26 +155,27 @@ const AuthDebugger = ({
155155
const clientInformation = await validateClientInformation(provider);
156156
updateAuthState({ oauthStep: "authorization_redirect" });
157157
try {
158+
let scope: string | undefined = undefined;
159+
if (metadata.scopes_supported) {
160+
// Request all supported scopes during debugging
161+
scope = metadata.scopes_supported.join(" ");
162+
}
158163
const { authorizationUrl, codeVerifier } = await startAuthorization(
159164
sseUrl,
160165
{
161166
metadata,
162167
clientInformation,
163168
redirectUrl: provider.redirectUrl,
169+
scope,
164170
},
165171
);
166172

167173
provider.saveCodeVerifier(codeVerifier);
168174

169-
if (metadata.scopes_supported) {
170-
const url = new URL(authorizationUrl.toString());
171-
url.searchParams.set("scope", metadata.scopes_supported.join(" "));
172-
updateAuthState({ authorizationUrl: url.toString() });
173-
} else {
174-
updateAuthState({ authorizationUrl: authorizationUrl.toString() });
175-
}
176-
177-
updateAuthState({ oauthStep: "authorization_code" });
175+
updateAuthState({
176+
authorizationUrl: authorizationUrl.toString(),
177+
oauthStep: "authorization_code",
178+
});
178179
} catch (error) {
179180
console.error("OAuth flow step error:", error);
180181
throw new Error(

0 commit comments

Comments
 (0)