User Profile Upserts Using C# Console Application

I’m looking to integrate User Profile upserts into an existing C# console app. Is there some code out in the wild that could be used as a template?

Is this related to Okta User Profiles in any way?

Yes. I’m trying to integrate user profile upserts into an existing C# console application

Are you looking to make API calls into Okta to get this information, or is this an OIDC application where that info would instead be in the ID token/Userinfo response?

The goal is to automatically apply updates to existing profile records and insert new records, from the c# console application.

Maybe you want to check out our .NET Management SDK to help facilitate user updates/creates.

Thanks for the suggestion. I’ll check it out.

I see a lot of ‘stuff’ in the Okta.idx.Sdk, but not enough specifics to be able to understand how to update a user profile.

Please refer to this sample code:

Configuration config = new Configuration();
config.OktaDomain = "https://{yourOrg}.okta.com";
config.ApiKey.Add("Authorization", "ApiKey");

var userApi = new UserApi(config);
var user = await userApi.GetUserAsync("testuser@domain.com");

user.Profile.PrimaryPhone = "555-555-5555";

var updateUserRequest = new UpdateUserRequest
{
    Profile = user.Profile
};

var updatedUser = await userApi.UpdateUserAsync(user.Id, updateUserRequest);

Note: hard-coding the Okta domain and API token works for quick tests, but for real projects you should use a more secure way of storing these values (such as environment variables). This library supports a few different configuration sources, covered in the configuration reference section.

1 Like