diff --git a/src/GoTrueClient.ts b/src/GoTrueClient.ts index 1dd15eab..b663f90e 100644 --- a/src/GoTrueClient.ts +++ b/src/GoTrueClient.ts @@ -308,6 +308,7 @@ export default class GoTrueClient { return this._handleProviderSignIn(credentials.provider, { redirectTo: credentials.options?.redirectTo, scopes: credentials.options?.scopes, + proxy: credentials.options?.proxy, queryParams: credentials.options?.queryParams, }) } @@ -750,12 +751,14 @@ export default class GoTrueClient { options: { redirectTo?: string scopes?: string + proxy?: string queryParams?: { [key: string]: string } } = {} ) { const url: string = this._getUrlForProvider(provider, { redirectTo: options.redirectTo, scopes: options.scopes, + proxy: options.proxy, queryParams: options.queryParams, }) // try to open on the browser @@ -945,6 +948,7 @@ export default class GoTrueClient { * Generates the relevant login URL for a third-party provider. * @param options.redirectTo A URL or mobile address to send the user to after they are confirmed. * @param options.scopes A space-separated list of scopes granted to the OAuth application. + * @param options.proxy A custom OAuth callback URL. The proxy must redirect (with query params retained) to the Authorize end-point * @param options.queryParams An object of key-value pairs containing query parameters granted to the OAuth application. */ private _getUrlForProvider( @@ -952,6 +956,7 @@ export default class GoTrueClient { options: { redirectTo?: string scopes?: string + proxy?: string queryParams?: { [key: string]: string } } ) { @@ -962,6 +967,9 @@ export default class GoTrueClient { if (options?.scopes) { urlParams.push(`scopes=${encodeURIComponent(options.scopes)}`) } + if (options?.proxy) { + urlParams.push(`proxy=${encodeURIComponent(options.proxy)}`) + } if (options?.queryParams) { const query = new URLSearchParams(options.queryParams) urlParams.push(query.toString()) diff --git a/src/lib/types.ts b/src/lib/types.ts index eec35966..8165849d 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -347,6 +347,8 @@ export type SignInWithOAuthCredentials = { redirectTo?: string /** A space-separated list of scopes granted to the OAuth application. */ scopes?: string + /** A custom OAuth callback URL. The proxy must redirect (with query params retained) to the Authorize end-point */ + proxy?: string, /** An object of query params */ queryParams?: { [key: string]: string } }