FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    changePassword returns 401

    Scheduled Pinned Locked Moved
    General Discussion
    2
    3
    337
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      john.bantoto
      last edited by

      I am using "@fusionauth/typescript-client": "^1.42.0" and tried to use the changePassword method.

      const fa = new FusionAuthClient(
        API_KEY,
        HOST,
        TENANT_ID
      );
      
      await fa.changePassword(undefined, {
        loginId: userEmail,
        password: "newPassword",
      });
      
      

      I always get a 401 response.

      I tried with a normal http request using axios and it's working so I think there is an issue with the changePassword method.

       await axiosInstance.post("/api/user/change-password", {
        loginId: user.email,
        password: newPassword,
      });
      

      I double checked the keys and even tried using the retrieveUser method which successfully returns the the user.

      The error response doesn't give much info. Does anyone have an idea on how to resolve?

      1 Reply Last reply Reply Quote 1
      • V
        vinicius.campitelli
        last edited by

        Hi there!

        In this scenario where you're providing the loginId instead of the changePasswordId, please use
        changePasswordByIdentity():

        await fa.changePasswordByIdentity({
          loginId: userEmail,
          password: "newPassword",
        });
        
        J 1 Reply Last reply Reply Quote 0
        • J
          john.bantoto @vinicius.campitelli
          last edited by

          @vinicius-campitelli thank you!

          1 Reply Last reply Reply Quote 1
          • First post
            Last post