okta / okta-sdk-nodejs

Node.js API Client for the Okta Platform API
Other
100 stars 58 forks source link

Support custom attributes in UserProfile type #238

Open JuanCaicedo opened 3 years ago

JuanCaicedo commented 3 years ago

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!

arvindkrishnakumar-okta commented 3 years ago

Thanks for posting!

@shuowu-okta can you help with this?

theseyi commented 3 years ago

@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...

JuanCaicedo commented 3 years ago

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

theseyi commented 3 years ago

@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... πŸ€”

mlahp7 commented 3 years ago

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

JuanCaicedo commented 3 years ago

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
}
mgrubb commented 1 year ago

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.

oleksandrpravosudko-okta commented 1 year ago

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