# SPA - authenticate user with password grant type

**URL:** <https://community.auth0.com/t/spa-authenticate-user-with-password-grant-type/68957>\
**Category:** Get Help\
**Tags:** spa, password, authentication, login, auth0\
**Created:** [September 1, 2021, 6:28pm UTC](https://community.auth0.com/t/spa-authenticate-user-with-password-grant-type/68957 "2021-09-01T18:28:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![katerina.chinnappan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/katerina.chinnappan/32/29398_2.png) [@katerina.chinnappan](https://community.auth0.com/u/katerina.chinnappan)\
**Post date:** [September 1, 2021, 6:28pm UTC](https://community.auth0.com/t/spa-authenticate-user-with-password-grant-type/68957/1 "2021-09-01T18:28:45Z")

</div>

I have an SPA registered in auth0 and connection enabled for username/password DB.

I have the scenario when users wish to update their passwords, they first have to enter their current password and that is validated in the backend. I know that there is no way to get the hashed passwords from Auth0, so I decided to authenticate the user by posting to the `oauth/token` endpoint. I am using the `password` grant type and my SPA has this grant type enabled. I am testing this with curl:

```auto
curl --request POST \
  --url https://MY_DOMAIN/oauth/token \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data '{"username":"username","password":"pass",client_id":"SPA_CLIENT_ID","client_secret":"SPA_CLIENT_SECRET","audience":"https://MY-DOMAIN/api/v2/","grant_type":"password","connection":"Username-Password-Authentication"}'

```

I am getting `{"error":"access_denied","error_description":"Unauthorized"}`.  
What am I doing wrong? I noticed that the `Token Endpoint Authentication Method` for my SPA is set to `NONE` and that cannot be changed.

---

<div class="post-metadata">

**Author:** ![marcus.baker](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/marcus.baker/32/8586_2.png) [@marcus.baker](https://community.auth0.com/u/marcus.baker)\
**Post date:** [September 2, 2021, 2:06am UTC](https://community.auth0.com/t/spa-authenticate-user-with-password-grant-type/68957/2 "2021-09-02T02:06:15Z")

</div>

Hi!

A SPA should not contain client secrets, that is why the **Token Endpoint Authentication Method** is set to None on a SPA in the Auth0 dashboard.

With this in mind, the resource owner password grant should not be called from a SPA.

You can initiate a password reset flow (via email) from your SPA using the [Change Password endpoint](https://auth0.com/docs/api/authentication?#change-password)

Hope this helps!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [September 2, 2021, 11:14am UTC](https://community.auth0.com/t/spa-authenticate-user-with-password-grant-type/68957/3 "2021-09-02T11:14:05Z")

</div>

Thanks for helping on this one Marcus!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [September 17, 2021, 11:15am UTC](https://community.auth0.com/t/spa-authenticate-user-with-password-grant-type/68957/4 "2021-09-17T11:15:01Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
