From a6d63819a6c3e06b5ed8ac40292fcca19efc15b6 Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Thu, 6 Aug 2026 11:30:46 -0700 Subject: [PATCH] fix(js): Send oidcPrompt and oidcLoginHint in external account requests --- .changeset/oidc-prompt-external-accounts.md | 5 +++++ packages/clerk-js/src/core/resources/ExternalAccount.ts | 9 +++++++-- packages/clerk-js/src/core/resources/User.ts | 4 +++- .../src/core/resources/__tests__/ExternalAccount.test.ts | 9 ++++++++- .../clerk-js/src/core/resources/__tests__/User.test.ts | 4 ++++ 5 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 .changeset/oidc-prompt-external-accounts.md diff --git a/.changeset/oidc-prompt-external-accounts.md b/.changeset/oidc-prompt-external-accounts.md new file mode 100644 index 00000000000..02d33b4fdee --- /dev/null +++ b/.changeset/oidc-prompt-external-accounts.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-js': patch +--- + +Fix `oidcPrompt` and `oidcLoginHint` being silently dropped from the Frontend API request in `user.createExternalAccount()` and `externalAccount.reauthorize()`. Both parameters were already accepted by the public types but never serialized, so providers such as Google would fall back to their default prompt behavior. They are now sent as `oidc_prompt` and `oidc_login_hint`. diff --git a/packages/clerk-js/src/core/resources/ExternalAccount.ts b/packages/clerk-js/src/core/resources/ExternalAccount.ts index 9f7d0dc90e1..6ab97a4e623 100644 --- a/packages/clerk-js/src/core/resources/ExternalAccount.ts +++ b/packages/clerk-js/src/core/resources/ExternalAccount.ts @@ -35,11 +35,16 @@ export class ExternalAccount extends BaseResource implements ExternalAccountReso } reauthorize = (params: ReauthorizeExternalAccountParams): Promise => { - const { additionalScopes, redirectUrl } = params || {}; + const { additionalScopes, redirectUrl, oidcPrompt, oidcLoginHint } = params || {}; return this._basePatch({ action: 'reauthorize', - body: { additional_scope: additionalScopes, redirect_url: redirectUrl }, + body: { + additional_scope: additionalScopes, + redirect_url: redirectUrl, + oidc_prompt: oidcPrompt, + oidc_login_hint: oidcLoginHint, + }, }); }; destroy = (): Promise => this._baseDelete(); diff --git a/packages/clerk-js/src/core/resources/User.ts b/packages/clerk-js/src/core/resources/User.ts index f3643bd1f13..ee4da919e6f 100644 --- a/packages/clerk-js/src/core/resources/User.ts +++ b/packages/clerk-js/src/core/resources/User.ts @@ -163,7 +163,7 @@ export class User extends BaseResource implements UserResource { }; createExternalAccount = async (params: CreateExternalAccountParams): Promise => { - const { strategy, redirectUrl, additionalScopes, enterpriseConnectionId } = params || {}; + const { strategy, redirectUrl, additionalScopes, enterpriseConnectionId, oidcPrompt, oidcLoginHint } = params || {}; const json = ( await BaseResource._fetch({ @@ -174,6 +174,8 @@ export class User extends BaseResource implements UserResource { redirect_url: redirectUrl, additional_scope: additionalScopes, enterprise_connection_id: enterpriseConnectionId, + oidc_prompt: oidcPrompt, + oidc_login_hint: oidcLoginHint, } as any, }) )?.response as unknown as ExternalAccountJSON; diff --git a/packages/clerk-js/src/core/resources/__tests__/ExternalAccount.test.ts b/packages/clerk-js/src/core/resources/__tests__/ExternalAccount.test.ts index 5e01de7b539..478fc8d2fa6 100644 --- a/packages/clerk-js/src/core/resources/__tests__/ExternalAccount.test.ts +++ b/packages/clerk-js/src/core/resources/__tests__/ExternalAccount.test.ts @@ -17,7 +17,12 @@ describe('External account', () => { BaseResource._fetch = vi.fn().mockReturnValue(Promise.resolve({ response: externalAccountJSON })); const externalAccount = new ExternalAccount({ id: targetId }, '/me/external_accounts'); - await externalAccount.reauthorize({ additionalScopes: ['read', 'write'], redirectUrl: 'https://test.com' }); + await externalAccount.reauthorize({ + additionalScopes: ['read', 'write'], + redirectUrl: 'https://test.com', + oidcPrompt: 'consent', + oidcLoginHint: 'test@test.com', + }); // @ts-ignore expect(BaseResource._fetch).toHaveBeenCalledWith({ @@ -26,6 +31,8 @@ describe('External account', () => { body: { additional_scope: ['read', 'write'], redirect_url: 'https://test.com', + oidc_prompt: 'consent', + oidc_login_hint: 'test@test.com', }, }); }); diff --git a/packages/clerk-js/src/core/resources/__tests__/User.test.ts b/packages/clerk-js/src/core/resources/__tests__/User.test.ts index ae380cce8aa..a86d25d2e15 100644 --- a/packages/clerk-js/src/core/resources/__tests__/User.test.ts +++ b/packages/clerk-js/src/core/resources/__tests__/User.test.ts @@ -28,6 +28,8 @@ describe('User', () => { strategy: 'oauth_dropbox', redirectUrl: 'https://www.example.com', additionalScopes: ['view'], + oidcPrompt: 'consent', + oidcLoginHint: 'test@test.com', }); // @ts-ignore @@ -38,6 +40,8 @@ describe('User', () => { redirect_url: 'https://www.example.com', strategy: 'oauth_dropbox', additional_scope: ['view'], + oidc_prompt: 'consent', + oidc_login_hint: 'test@test.com', }, }); });