Skip to content
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

Add ability to use server callback url for start of oauth2 flow #715

Merged
merged 4 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/@magic-ext/oauth2/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export class OAuthExtension extends Extension.Internal<'oauth2'> {
}

if (successResult?.oauthAuthoriationURI) {
window.location.href = successResult.oauthAuthoriationURI;
window.location.href = successResult.useMagicServerCallback
? // @ts-ignore - this.sdk.endpoint is marked protected but we need to access it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about adding a public getter function for endpoint so we don't have to do this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was thinking the same thing since this is protected. Didn't want to muddy up this PR so perhaps we can make a separate PR for this?

new URL(successResult.oauthAuthoriationURI, this.sdk.endpoint).href
: successResult.oauthAuthoriationURI;
}

resolve();
Expand Down
1 change: 1 addition & 0 deletions packages/@magic-ext/oauth2/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export type OpenIDConnectUserInfo = OpenIDConnectProfile &

export interface OAuthRedirectStartResult {
oauthAuthoriationURI?: string;
useMagicServerCallback?: boolean;
}

export interface OAuthRedirectResult {
Expand Down
Loading