Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/oidc-prompt-external-accounts.md
Original file line number Diff line number Diff line change
@@ -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`.
9 changes: 7 additions & 2 deletions packages/clerk-js/src/core/resources/ExternalAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@ export class ExternalAccount extends BaseResource implements ExternalAccountReso
}

reauthorize = (params: ReauthorizeExternalAccountParams): Promise<ExternalAccountResource> => {
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<void> => this._baseDelete();
Expand Down
4 changes: 3 additions & 1 deletion packages/clerk-js/src/core/resources/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class User extends BaseResource implements UserResource {
};

createExternalAccount = async (params: CreateExternalAccountParams): Promise<ExternalAccountResource> => {
const { strategy, redirectUrl, additionalScopes, enterpriseConnectionId } = params || {};
const { strategy, redirectUrl, additionalScopes, enterpriseConnectionId, oidcPrompt, oidcLoginHint } = params || {};

const json = (
await BaseResource._fetch<ExternalAccountJSON>({
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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',
},
});
});
Expand Down
4 changes: 4 additions & 0 deletions packages/clerk-js/src/core/resources/__tests__/User.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ describe('User', () => {
strategy: 'oauth_dropbox',
redirectUrl: 'https://www.example.com',
additionalScopes: ['view'],
oidcPrompt: 'consent',
oidcLoginHint: 'test@test.com',
});

// @ts-ignore
Expand All @@ -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',
},
});
});
Expand Down
Loading