Aksha Malik
02/16/2026, 4:13 PMasync ssoExchangeCodeForToken(code: string, customerId?: number): Promise<any> {
try {
console.log("[DescopeService] Exchanging SSO code for token:", code);
const resp = await this.descopeClient.saml.exchange(code);
if (!resp.ok) {
console.error('[DescopeService] SSO Exchange Error:', resp.error);
throw new Error(resp.error.errorMessage || 'Failed to verify SSO code');
}
const { sessionJwt, refreshJwt, user } = resp.data;
// Set customerID if provided
if (customerId && user.loginIds?.[0]) {
try {
const result = await this.descopeClient.management.user.updateCustomAttribute(
user.loginIds[0],
'customerId',
customerId
);
console.log(`[DescopeService] Updated customerID for user ${user.loginIds[0]}:`, result);
console.log(`[DescopeService] Set customerID: ${customerId} for user: ${user.loginIds[0]}`);
} catch (updateError) {
console.error('[DescopeService] Failed to update customerID:', updateError);
// Don't fail auth flow for attribute update errors
}
}
return {
sessionJwt,
refreshJwt,
user,
tenantId: user.userTenants?.[0]?.tenantId || null
};
} catch (error) {
console.error('[DescopeService] Exception in ssoExchangeCodeForToken:', error);
throw error;
}
}
but it is not updating the customerId set as custom Attribute
these are my logs
[DescopeService] Updated customerID for user h3suqbju8jmkwoblw9rb-ilg4jxv1tyokyh-hkhkhfs-t2z3xkq4xiwqveygkolqpcwrcilt: {
code: 200,
ok: true,
response: Response {
size: 0,
timeout: 0,
text: [Function (anonymous)],
json: [Function (anonymous)],
clone: [Function (anonymous)],
[Symbol(Body internals)]: { body: [Gunzip], disturbed: true, error: null },
[Symbol(Response internals)]: {
url: '<https://api.descope.com/v1/mgmt/user/update/customAttribute>',
status: 200,
statusText: 'OK',
headers: [Headers],
counter: 0
}
},
data: {
loginIds: [
'h3suqbju8jmkwoblw9rb-ilg4jxv1tyokyh-hkhkhfs-t2z3xkq4xiwqveygkolqpcwrcilt'
],
userId: 'U39l6687N1DZ5ZyCs0V9IZHhoDm2',
name: 'Aksha Malik',
email: '<mailto:amalik@nucompass.com|amalik@nucompass.com>',
phone: '',
verifiedEmail: true,
verifiedPhone: false,
roleNames: [],
userTenants: [ [Object] ],
status: 'enabled',
externalIds: [
'h3suqbju8jmkwoblw9rb-ilg4jxv1tyokyh-hkhkhfs-t2z3xkq4xiwqveygkolqpcwrcilt'
],
picture: '<https://graph.microsoft.com/v1.0/me/photo/$value>',
test: false,
customAttributes: { customerId: '' },
createdTime: 1771258131,
TOTP: false,
SAML: false,
OAuth: { T2z3XKQ4XIWQveygKOlQPcWRciLt: true },
webauthn: false,
password: false,
ssoAppIds: [],
givenName: 'Aksha',
middleName: '',
familyName: 'Malik',
SCIM: false,
push: false,
permissions: [],
OIDC: true
customAttributes: { customerId: '' },
createdTime: 1771258131,
TOTP: false,
SAML: false,
OAuth: { T2z3XKQ4XIWQveygKOlQPcWRciLt: true },
webauthn: false,
password: false,
ssoAppIds: [],
givenName: 'Aksha',
middleName: '',
familyName: 'Malik',
SCIM: false,
push: false,
permissions: [],
OIDC: true
SAML: false,
OAuth: { T2z3XKQ4XIWQveygKOlQPcWRciLt: true },
webauthn: false,
password: false,
ssoAppIds: [],
givenName: 'Aksha',
middleName: '',
familyName: 'Malik',
SCIM: false,
push: false,
permissions: [],
OIDC: true
password: false,
ssoAppIds: [],
givenName: 'Aksha',
middleName: '',
familyName: 'Malik',
SCIM: false,
push: false,
permissions: [],
OIDC: true
middleName: '',
familyName: 'Malik',
SCIM: false,
push: false,
permissions: [],
OIDC: true
familyName: 'Malik',
SCIM: false,
push: false,
permissions: [],
OIDC: true
push: false,
permissions: [],
OIDC: true
}
}
}
}
}
[DescopeService] Set customerID: 754 for user: h3suqbju8jmkwoblw9rb-ilg4jxv1tyokyh-hkhkhfs-t2z3xkq4xiwqveygkolqpcwrcilt
attached screenshot from descope console as well for ref.Aditya Arakal
02/16/2026, 7:25 PMAksha Malik
02/17/2026, 6:55 AMAksha Malik
02/17/2026, 6:57 AMAditya Arakal
02/17/2026, 7:10 AMAksha Malik
02/17/2026, 7:11 AM