Using static client data as DCR fallback
This commit is contained in:
parent
aa6a98ae52
commit
b99b3d29d9
1 changed files with 27 additions and 9 deletions
|
|
@ -88,16 +88,34 @@ export const oauthTransitions: Record<OAuthStep, StateTransition> = {
|
|||
clientMetadata.scope = scopesSupported.join(" ");
|
||||
}
|
||||
|
||||
const fullInformation = await registerClient(context.serverUrl, {
|
||||
metadata,
|
||||
clientMetadata,
|
||||
});
|
||||
// Try DCR first, with static client as fallback
|
||||
try {
|
||||
const fullInformation = await registerClient(context.serverUrl, {
|
||||
metadata,
|
||||
clientMetadata,
|
||||
});
|
||||
|
||||
context.provider.saveClientInformation(fullInformation);
|
||||
context.updateState({
|
||||
oauthClientInfo: fullInformation,
|
||||
oauthStep: "authorization_redirect",
|
||||
});
|
||||
context.provider.saveClientInformation(fullInformation);
|
||||
context.updateState({
|
||||
oauthClientInfo: fullInformation,
|
||||
oauthStep: "authorization_redirect",
|
||||
});
|
||||
console.log({ fullInformation });
|
||||
return;
|
||||
} catch (dcrError) {
|
||||
console.error(dcrError);
|
||||
|
||||
// DCR failed, fallback to preregistered client
|
||||
const existingClientInfo = await context.provider.clientInformation();
|
||||
if (!existingClientInfo) {
|
||||
console.error("Neither dynamic client registration or preregistered client information was found");
|
||||
throw dcrError;
|
||||
}
|
||||
context.updateState({
|
||||
oauthClientInfo: existingClientInfo,
|
||||
oauthStep: "authorization_redirect",
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue