OKTA SDK DotNet: How do I force a user to change password

When a user signs on for the first time, I want to force the user to change the password they are given.

I am able to create the user with a password.

And then activate the user, with an email (which is what I want). (See below)

But, I can not figure out a way, using the OKTA SDK for dotNote, to then expire the password to force the user to change it.

I did find information related to nextLogin = changePassword. But, I can’t seem to figure out how to use it with the SDK. (See below.)

Within the SDK there is a UserNextLogin class but I don’t know if that as anything to do with it.

Any help would be appreciated.

        var oktaUser = await client.Users.CreateUserAsync(new CreateUserWithPasswordOptions
        {
            // User profile object
            Profile = new UserProfile
            {
                FirstName = "Anakin8",
                LastName = "Skywalker8",
                Email = "test@gmail.com",
                Login = "darth.vader12345678",
                
            },
            Password = "D1sturB1ng!",
            Activate = false,
        });

        await oktaUser.ActivateAsync(sendEmail: false);

        var userNestNextLogin = UserNextLogin.ChangePassword;

Hi @rcorkery

If you take a look at the SDK source code, you’ll see that you actually need to pass nextLogin=changePassword in as a query parameter to CreateUserAsync in order to prompt the user to change their password the next time they log in.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.