Start a new topic

Logged in User Cannot Change their Password, per documentation

Hi All,


I am trying to use the documented feature and method for a logged in user to simply change their password. This does not work and I get a message a few error messages shown below:


Error: The credentials used to authenticate this request are not authorized to run this operation. Please retry your request with appropriate credentials.


Error: [Please authenticate as an app End User or as the app admin using the Master secret to run this operation]


The method I am using comes from the documentation that seems to suggest this is possible. Here is the method where newPwd is the new password to set. 


        if let user = Kinvey.sharedClient.activeUser {

            user.save(newPassword: newPwd, options: nil) { result  in

            switch result {

            case .success:

                print("Success")

            case .failure(let error):

                print("Error")

                }

            }

        }


Your help doc has this entry and this is what I am trying to do. Can this work or not? The user is already logged in but the error says not possible without master secret which we cannot use.


Change Password

If the user is already logged in but wants to change the password, simply set a new password property on the user object and save the user.



John,


This error is shown when you don't authenticate using an app end user. Can you please try printing the active user before calling any function? Let me know what you see. Yesterday, I have also answered your questions on the Freshdesk Support ticket.


Thanks,

Pranav

We log the user in when they first run the app. Printing active user yields this string. <Kinvey.User: 0x14dd4d940>I am checking for active user before calling the method.


if let user = Kinvey.sharedClient.activeUser {

            user.changePassword(newPassword: newPwd, options: nil, completionHandler: { (result) in

                switch result {

                case .success:

                    print("Success")

                case .failure(let error):

                    print(error.localizedDescription)

                }

            })

        }

This is exactly what I’ve been looking for. It solved very quickly the problem I was having.

rolling sky

Login or Signup to post a comment