Change password from the server

how do I change the password (from the email + password credentiales) from the server?

My understanding what that authClient is meant to be used in the client and that, in the server, I am expected to use auth.api.changePassword, as in:

 const { user } = await auth.api.changePassword({
        body: {
          newPassword: parsedInput.newPassword,
          currentPassword: parsedInput.oldPassword,  
        },
      });
`


However, when doing that, I get:
error [APIError] {
  status: 'UNAUTHORIZED',
  body: undefined,
  headers: {},
  statusCode: 401
}


I have also tried passing the session token in the changePassword method, with the same output (UNAUTHORIZED status).


what am I missing? what is the suggested way to do this?

Thank you 🙏🏻
Solution
You need to pass the
headers
of the user making the request.
Was this page helpful?