@@ -71,6 +71,13 @@ export interface OAuthClientProvider {
71
71
* the authorization result.
72
72
*/
73
73
codeVerifier ( ) : string | Promise < string > ;
74
+
75
+ /**
76
+ * Use OpenID Provider configuration information for authorization
77
+ * server metadata.
78
+ * https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig
79
+ */
80
+ useOidcProviderConfiguration ?( ) : boolean | Promise < boolean > ;
74
81
}
75
82
76
83
export type AuthResult = "AUTHORIZED" | "REDIRECT" ;
@@ -111,7 +118,9 @@ export async function auth(
111
118
console . warn ( "Could not load OAuth Protected Resource metadata, falling back to /.well-known/oauth-authorization-server" , error )
112
119
}
113
120
114
- const metadata = await discoverOAuthMetadata ( authorizationServerUrl ) ;
121
+ const metadata = await discoverOAuthMetadata ( authorizationServerUrl , {
122
+ useOidcConfig : await provider . useOidcProviderConfiguration ?.( )
123
+ } ) ;
115
124
116
125
// Handle client registration if needed
117
126
let clientInformation = await Promise . resolve ( provider . clientInformation ( ) ) ;
@@ -267,9 +276,15 @@ export async function discoverOAuthProtectedResourceMetadata(
267
276
*/
268
277
export async function discoverOAuthMetadata (
269
278
authorizationServerUrl : string | URL ,
270
- opts ?: { protocolVersion ?: string } ,
279
+ opts ?: {
280
+ protocolVersion ?: string
281
+ useOidcConfig ?: boolean
282
+ } ,
271
283
) : Promise < OAuthMetadata | undefined > {
272
- const url = new URL ( "/.well-known/oauth-authorization-server" , authorizationServerUrl ) ;
284
+ const metadataPath = opts ?. useOidcConfig ?
285
+ "openid-configuration" :
286
+ "oauth-authorization-server" ;
287
+ const url = new URL ( `/.well-known/${ metadataPath } ` , authorizationServerUrl ) ;
273
288
let response : Response ;
274
289
try {
275
290
response = await fetch ( url , {
0 commit comments