Consume ChangePassword via okta sdk

Hi There,

We are trying to consume okta’s change password api via okta sdk in java but facing change in forming the request.

Could you please provide a sample how we can for ChangePasswordRequest.

Thank you.

Hi @luckyprashant,

If you’re using okta java sdk version 1.x,
you can use the following code template to change password -

UserCredentials credentials = user.changePassword(client.instantiate(ChangePasswordRequest)
            .setOldPassword(client.instantiate(PasswordCredential).setValue("Abcd1234".toCharArray()))
            .setNewPassword(client.instantiate(PasswordCredential).setValue("1234Abcd".toCharArray())))

Test code in groovy can be found here

2 Likes