Skip to content

Commit 66dec56

Browse files
authored
feat(auth): support custom scope in authorization requests (#491)
* feat(auth): support custom scope in authorization requests * fix(auth): default to provider's scope if not provided
1 parent bac916e commit 66dec56

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/client/auth.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,14 @@ export class UnauthorizedError extends Error {
8484
*/
8585
export async function auth(
8686
provider: OAuthClientProvider,
87-
{ serverUrl, authorizationCode }: { serverUrl: string | URL, authorizationCode?: string }): Promise<AuthResult> {
87+
{ serverUrl,
88+
authorizationCode,
89+
scope,
90+
}: {
91+
serverUrl: string | URL;
92+
authorizationCode?: string;
93+
scope?: string;
94+
}): Promise<AuthResult> {
8895
const metadata = await discoverOAuthMetadata(serverUrl);
8996

9097
// Handle client registration if needed
@@ -146,7 +153,7 @@ export async function auth(
146153
metadata,
147154
clientInformation,
148155
redirectUrl: provider.redirectUrl,
149-
scope: provider.clientMetadata.scope
156+
scope: scope || provider.clientMetadata.scope,
150157
});
151158

152159
await provider.saveCodeVerifier(codeVerifier);

0 commit comments

Comments
 (0)