Skip to content

Commit 1336dbd

Browse files
authored
Merge pull request #286 from supabase/j0_add_query_params
Add query params
2 parents 5a3a039 + 16e3c66 commit 1336dbd

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/GoTrueApi.ts

+5
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export default class GoTrueApi {
6767
options: {
6868
redirectTo?: string
6969
scopes?: string
70+
queryParams?: { [key: string]: string }
7071
}
7172
) {
7273
const urlParams: string[] = [`provider=${encodeURIComponent(provider)}`]
@@ -76,6 +77,10 @@ export default class GoTrueApi {
7677
if (options?.scopes) {
7778
urlParams.push(`scopes=${encodeURIComponent(options.scopes)}`)
7879
}
80+
if(options?.queryParams) {
81+
const query = new URLSearchParams(options.queryParams)
82+
urlParams.push(`${query}`)
83+
}
7984
return `${this.url}/authorize?${urlParams.join('&')}`
8085
}
8186

src/GoTrueClient.ts

+4
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ export default class GoTrueClient {
201201
shouldCreateUser?: boolean
202202
scopes?: string
203203
captchaToken?: string
204+
queryParams?: { [key: string]: string }
204205
} = {}
205206
): Promise<{
206207
session: Session | null
@@ -250,6 +251,7 @@ export default class GoTrueClient {
250251
return this._handleProviderSignIn(provider, {
251252
redirectTo: options.redirectTo,
252253
scopes: options.scopes,
254+
queryParams: options.queryParams,
253255
})
254256
}
255257
if (oidc) {
@@ -559,11 +561,13 @@ export default class GoTrueClient {
559561
options: {
560562
redirectTo?: string
561563
scopes?: string
564+
queryParams?: { [key: string]: string }
562565
} = {}
563566
) {
564567
const url: string = this.api.getUrlForProvider(provider, {
565568
redirectTo: options.redirectTo,
566569
scopes: options.scopes,
570+
queryParams: options.queryParams
567571
})
568572

569573
try {

0 commit comments

Comments
 (0)