Skip to content

Commit 5740640

Browse files
authored
feat(backend,clerk-js): Add providerUserId field to ExternalAccount (#7778)
1 parent 1fe87ac commit 5740640

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

.changeset/legal-crabs-shout.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@clerk/clerk-js': minor
3+
'@clerk/backend': minor
4+
---
5+
6+
Add `providerUserId` field to `ExternalAccount` resource as the preferred way to access the unique user ID from the OAuth provider. The existing `externalId` field is now deprecated in favor of `providerUserId` for better clarity and consistency across the API.

packages/backend/src/api/resources/ExternalAccount.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ export class ExternalAccount {
1616
* The provider name (e.g., `google`).
1717
*/
1818
readonly provider: string,
19+
/**
20+
* The unique ID of the user in the provider.
21+
*/
22+
readonly providerUserId: string,
1923
/**
2024
* The identification with which this external account is associated.
2125
*/
2226
readonly identificationId: string,
2327
/**
2428
* The unique ID of the user in the provider.
29+
* @deprecated Use providerUserId instead
2530
*/
2631
readonly externalId: string,
2732
/**
@@ -70,6 +75,7 @@ export class ExternalAccount {
7075
return new ExternalAccount(
7176
data.id,
7277
data.provider,
78+
data.provider_user_id,
7379
data.identification_id,
7480
data.provider_user_id,
7581
data.approved_scopes,

packages/clerk-js/src/core/resources/__tests__/ExternalAccount.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ describe('External account', () => {
99
const externalAccountJSON = {
1010
object: 'external_account',
1111
id: targetId,
12+
provider_user_id: 'test_provider_user_id',
13+
identification_id: 'test_identification_id',
1214
};
1315

1416
// @ts-ignore
@@ -35,6 +37,8 @@ describe('External account', () => {
3537
object: 'external_account',
3638
id: targetId,
3739
deleted: true,
40+
provider_user_id: 'test_provider_user_id',
41+
identification_id: 'test_identification_id',
3842
};
3943

4044
// @ts-ignore

0 commit comments

Comments
 (0)