Skip to content
Back

updatePassword invalid credentials error in react native

  • 0
  • React Native
qorinn
23 Jun, 2025, 18:10

This is my code:

TypeScript
      const result = await account.updatePassword(
        newPassword
      );

This is my error:

TypeScript
[AppwriteException: Invalid credentials. Please check the email and password.]
TL;DR
Developers were discussing methods to update a user's password in a React Native app using Appwrite. The error "Invalid credentials" was occurring because the old password was not being passed in the updatePassword function. The solution was to include the old password parameter to successfully update the user's password.
Steven
23 Jun, 2025, 18:18

you need to pass the old password

Axistro
23 Jun, 2025, 18:19

I was about to say same thing But in the docs it says old password is optional?

TypeScript
const result = await account.updatePassword(
    '', // password
    'password' // oldPassword (optional)
);

From the docs

Steven
23 Jun, 2025, 18:31
Axistro
23 Jun, 2025, 18:32

Ahh, my bad. Did not read that 😐

qorinn
23 Jun, 2025, 18:34

I used OTP for forgotten password and wanted an option to update their password. I can't use oldPassword because the point is the user had forgot it:/

qorinn
23 Jun, 2025, 18:37

I'd rather not use magicUrl as I'm developing a mobile app. With magicUrl I would either need to set up a website or host a page of my react native app. Or any other ideas?

qorinn
23 Jun, 2025, 18:46

Oh I see I could open my app from magicURL if I set the url param to one that opens my app. But it only accepts URLs I set for Platform in my Appwrite Console. Not sure if that url could open my app? Even if it could, I'd rather not depend on this url as it may not work depending on the user's device

Axistro
23 Jun, 2025, 18:48

An url can open your app if you have setup universal linking. I dont know if it will accept deeplink scheme....

qorinn
23 Jun, 2025, 18:50

yes, a URL can, BUT I can only set the Platforms as URL from my Appwrite console. Not sure if those can work as one that opens my app

Axistro
23 Jun, 2025, 18:51

what do you mean? Can you explain a bit?

qorinn
23 Jun, 2025, 18:52
Axistro
23 Jun, 2025, 18:52

And were you trying this method? User forgot password-> send otp->check otp-> update new password?

qorinn
23 Jun, 2025, 18:52

yes, exactly

Axistro
23 Jun, 2025, 18:55

I am not fully understanding it.
Let me clear the universal linking from my part, In your hosted site you can put a json file with your app sha256 key and package id. When you install that app android sends a ping to that domain and checks validity. Now your app will always open the links related to the domain you shared. Like opening fb app with facebook.com. i am sorry if I did not get your requirements right

Axistro
23 Jun, 2025, 18:57

That is not possible afaik. For updating user password you will call passwordrecovery method with email of the user and your redirection url. Now appwrite sends a fully modified link with secret code and user id. User clicks this and it opens your app where you can catch the params and use then to update the recovery. You can still use your own method but you have to make it yourself with your workflow and verification with cloud functions

qorinn
23 Jun, 2025, 18:58

I don't host a site, and that's what I'm trying to avoid

Axistro
23 Jun, 2025, 18:58

Ok You can still use cloud functions

Axistro
23 Jun, 2025, 18:59

Check this out

qorinn
23 Jun, 2025, 19:00

This is true, but I don't find opening my app from a url reliable. Often times when I use a url like so, it would open in browser instead of the app

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more