Skip to content

Commit 6d0fd5f

Browse files
authored
feat: complete OIDC support for Apple, Google and others (#690)
Updates the `signInWithIdToken` API: - No longer experimental. - Adds optional `access_token` parameter. - Updates the types on `provider`. - More docs. To be merged after release of: supabase/auth#1108
1 parent 4c2b3c6 commit 6d0fd5f

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/GoTrueClient.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,22 +496,21 @@ export default class GoTrueClient {
496496
}
497497

498498
/**
499-
* Allows signing in with an ID token issued by certain supported providers.
500-
* The ID token is verified for validity and a new session is established.
501-
*
502-
* @experimental
499+
* Allows signing in with an OIDC ID token. The authentication provider used
500+
* should be enabled and configured.
503501
*/
504502
async signInWithIdToken(credentials: SignInWithIdTokenCredentials): Promise<AuthTokenResponse> {
505503
await this._removeSession()
506504

507505
try {
508-
const { options, provider, token, nonce } = credentials
506+
const { options, provider, token, access_token, nonce } = credentials
509507

510508
const res = await _request(this.fetch, 'POST', `${this.url}/token?grant_type=id_token`, {
511509
headers: this.headers,
512510
body: {
513511
provider,
514512
id_token: token,
513+
access_token,
515514
nonce,
516515
gotrue_meta_security: { captcha_token: options?.captchaToken },
517516
},

src/lib/types.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -494,13 +494,13 @@ export type SignInWithOAuthCredentials = {
494494
}
495495

496496
export type SignInWithIdTokenCredentials = {
497-
/**
498-
* Only Apple and Google ID tokens are supported for use from within iOS or Android applications.
499-
*/
500-
provider: 'google' | 'apple'
501-
/** ID token issued by Apple or Google. */
497+
/** Provider name or OIDC `iss` value identifying which provider should be used to verify the provided token. Supported names: `google`, `apple`, `azure`, `facebook`, `keycloak` (deprecated). */
498+
provider: 'google' | 'apple' | 'azure' | 'facebook' | string
499+
/** OIDC ID token issued by the specified provider. The `iss` claim in the ID token must match the supplied provider. Some ID tokens contain an `at_hash` which require that you provide an `access_token` value to be accepted properly. If the token contains a `nonce` claim you must supply the nonce used to obtain the ID token. */
502500
token: string
503-
/** If the ID token contains a `nonce`, then the hash of this value is compared to the value in the ID token. */
501+
/** If the ID token contains an `at_hash` claim, then the hash of this value is compared to the value in the ID token. */
502+
access_token?: string
503+
/** If the ID token contains a `nonce` claim, then the hash of this value is compared to the value in the ID token. */
504504
nonce?: string
505505
options?: {
506506
/** Verification token received when the user completes the captcha on the site. */

0 commit comments

Comments
 (0)