-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not restart auth flow on failed auth callback #389
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@osdk/legacy-client": patch | ||
--- | ||
|
||
Do not restart auth flow on failed auth callback |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,12 @@ export async function getTokenWithCodeVerifier( | |
multipassContextPath?: string, | ||
): Promise<OAuthToken> { | ||
const parsedUrl = new URLSearchParams(url.substring(url.indexOf("?"))); | ||
|
||
const error = parsedUrl.get("error"); | ||
if (error) { | ||
throw new Error("Error received from server: " + error); | ||
} | ||
|
||
const code = parsedUrl.get("code"); | ||
if (!code) { | ||
throw new Error("Code parameter missing in URL: " + url); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we receive the callback with the error in the url query param then we would have failed here in the past so I |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,7 +228,7 @@ export function createPublicOauthClient( | |
if (process?.env?.NODE_ENV !== "production") { | ||
// eslint-disable-next-line no-console | ||
console.warn( | ||
"Failed to get OAuth2 token using PCKE, removing PCKE and starting a new auth flow", | ||
"Failed to get OAuth2 token using PKCE, removing PKCE and starting a new auth flow", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that the 2.0 oauth is a bit out of sync now but applied this rename across the repo There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you |
||
e, | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rename here and the move from local to session storage does leave behind old values but given that this state should only live for the lifetime of one auth flow there shouldn't be a risk of breaking a user's login