How can i change password

I have tried to change the password but I am facing invalid error but also its token work for getting user information every time but it’s not working on password change.

{
attributes :{
error : “Invalid token”
},
error : Unauthorized,
message : “Invalid token”,
statusCode : 401
}

let attributes = Auth0.UserPatchAttributes().password("123456", connection: "Username-Password-Authentication")
Auth0.users(token: idToken).patch( user.id.replacingOccurrences(of: "auth0|", with: ""), attributes: attributes).start { result in
	DispatchQueue.main.async {
		switch result {
			case .success(let userInfo):
				print(userInfo)
				completion(nil)

			case .failure(let error):
				completion(error)
		}
	}
}

i am getting id token from stored credential

credentialsManager.credentials { error, credentials in
	guard error == nil , let credentials = credentials else {
		print(error!)
		return
	}
	self .idToken = credentials.idToken ?? ""
	self .accessToken = credentials.accessToken ?? ""
}

please suggest me if I miss something. I have reviewed the documentation but no method found for password change so please help me to find the solution.

Swift: 5, Cocoapods

1 Like

Hi @hardik.mavani9697,

Welcome and thank you for posting in Auth0 Community! :wave:

Can you please share what the use case is? What is the desired flow that you are trying to archive? Have you seen our documentation on password change? Change Users' Passwords