okta-sdk-nodejs icon indicating copy to clipboard operation
okta-sdk-nodejs copied to clipboard

Support custom attributes in UserProfile type

Open JuanCaicedo opened this issue 3 years ago β€’ 8 comments

Hi there! I'm looking to switch over to use your new typescript definitions (thank you! πŸ˜€) and am running into an issue.

My organization currently defines some custom attributes as part of the user profile. However, it looks to me like the UserProfile type has not way of accounting for these other attributes, which is causing my code that tries to access them to not compile.

I wanted to flag this and see if this is a known issue or if there's something I'm overlooking πŸ˜„

If this does need to be addressed, I'm not sure what would be a good strategy. Perhaps leveraging somehow generics on the User/UserProfile type to represent the custom properties?

Thank you!

JuanCaicedo avatar Apr 15 '21 22:04 JuanCaicedo

Thanks for posting!

@shuowu-okta can you help with this?

arvindkrishnakumar-okta avatar Apr 15 '21 22:04 arvindkrishnakumar-okta

@JuanCaicedo how are you retrieving the custom properties on the user profile? The getUser api does not seem to return custom properties even outside of typing constraints...

theseyi avatar Apr 24 '21 23:04 theseyi

@theseyi When I call getUser it comes back with a profile including those custom properties πŸ˜…

JuanCaicedo avatar Apr 28 '21 23:04 JuanCaicedo

@theseyi When I call getUser it comes back with a profile including those custom properties πŸ˜…

I see, I guess someone already updated the schΓ©ma in your Okta org to apply those custom fields to the user type... πŸ€”

theseyi avatar Apr 29 '21 07:04 theseyi

We're using custom properties as well, any updates on this?

mlahp7 avatar Jun 09 '21 02:06 mlahp7

We ended building our own profile type by

type OktaUser = Awaited<ReturnType<Client['createUser']>>
type OktaUserProfile = OktaUser['profile']
interface CustomUserProfile extends OktaUserProfile {
  customProperty?: string
}

export interface CustomOktaUser extends OktaUser {
  profile: CustomUserProfile
}

JuanCaicedo avatar Jun 09 '21 16:06 JuanCaicedo

I'm having a similar issue but with Group profiles. Whenever I try to access any of the custom attributes I get 'property' does not exists on type 'GroupProfile'. Any guidance from Okta would be appreciated.

mgrubb avatar Nov 07 '22 21:11 mgrubb

@mgrubb index signature was added for extensible types in 6.6.0 - can you please check if it works for you?