diff --git a/src/GoTrueClient.ts b/src/GoTrueClient.ts index 76c5e4747..3a064b2ff 100644 --- a/src/GoTrueClient.ts +++ b/src/GoTrueClient.ts @@ -352,6 +352,7 @@ export default class GoTrueClient { redirectTo: credentials.options?.redirectTo, scopes: credentials.options?.scopes, queryParams: credentials.options?.queryParams, + skipBrowserRedirect: credentials.options?.skipBrowserRedirect, }) } @@ -933,6 +934,7 @@ export default class GoTrueClient { redirectTo?: string scopes?: string queryParams?: { [key: string]: string } + skipBrowserRedirect?: boolean } = {} ) { const url: string = this._getUrlForProvider(provider, { @@ -941,7 +943,7 @@ export default class GoTrueClient { queryParams: options.queryParams, }) // try to open on the browser - if (isBrowser()) { + if (isBrowser() && !options.skipBrowserRedirect) { window.location.assign(url) } return { data: { provider, url }, error: null } diff --git a/src/lib/types.ts b/src/lib/types.ts index df5e4de46..64ded0654 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -440,6 +440,8 @@ export type SignInWithOAuthCredentials = { scopes?: string /** An object of query params */ queryParams?: { [key: string]: string } + /** If set to true does not immediately redirect the current browser context to visit the OAuth authorization page for the provider. */ + skipBrowserRedirect?: boolean } } @@ -912,8 +914,8 @@ export type CallRefreshTokenResult = export type Pagination = { [key: string]: any - nextPage: number | null, - lastPage: number, + nextPage: number | null + lastPage: number total: number }