how to reset password correctly?

default discord avatar
kouohhashi
2 months ago
1 1

Hi, I'm trying to reset password through API.

I'm trying to follow the document.
And I put token that I got from {cms-url}/api/{user-collection}/me endpoint.

try {
  const req = await fetch('{cms-url}/api/{user-collection}/reset-password', {
    method: "POST", 
    credentials: "include",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      token: "7eac3830ffcfc7f9f66c00315dabeb11575dba91",
      password: "newPassword"
    }),
  })
  const data = await req.json()
} catch (err) {
  console.log(err)
}

But i got an "Token is either invalid or has expired." error.

And it seems my token form fetchme is way longer than the token on document.

Where can I get right token to reset password?

Thanks in advance.

  • default discord avatar
    hjbugajski
    2 months ago

    @kouohhashi The token you're looking for is located in the link that is emailed to the user generated from the /forgot-password endpoint. Here is the forgot password section in the documentation, and here is how to configure email for your payload server.

Open the post
Continue the discussion in GitHub
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.