pwa-kit: [BUG] Reset Password is not working
Summary
When using “Reset Password” the app returns the error “Your access-token is invalid and could not be used to identify the API client.”. This happens regardless if the email is known to the system or not.
Steps To Reproduce
- open https://pwa-kit.mobify-storefront.com/en-GB/login
- click “Forgot Password!”
- enter valid email
- click “Reset Password”
- see the error “Your access-token is invalid and could not be used to identify the API client.”
Expected result
- no error message
Actual result
- error message “Your access-token is invalid and could not be used to identify the API client.”
System Information (as applicable)
Browser: Chrome Version 97.0.4692.99 Node version: pwa-kit version: 1.3 Desktop OS: Mobile Device Info:
Happens on the official test system, on our test system and locally.
Additional information
I tried to trace down this to myself but was not successful.
It seems that the underlying call
https://{{short_code}}.api.commercecloud.salesforce.com/customer/shopper-customers/v1/organizations/{{organization_id}}/customers/password/actions/create-reset-token?siteId={{site_id}}
is executed with the SLAS token and this does not work. I can reproduce the same error in Postman.
The documentation actually says to use the AM based token (https://account.demandware.com/dwsso/oauth2/access_token). But this did also not work for me and returns
“Your access-token is valid, but you have no permissions to access the resource.”.
The related OCAPI permission is set but there is no related AuthZ Scope that could be set.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 1
- Comments: 16 (9 by maintainers)
To fix the Password Reset functionality in your Progressive Web App (PWA), follow these steps: Step 1: Generate an Admin token by accessing the following URL: https://account.demandware.com/dw/oauth2/access_token Note: Make sure to set the scope in the request Body to SALESFORCE_COMMERCE_API:<tenantId> sfcc.shopper-customers.login Step 2: Once you have the token generated in Step 1, use it for Authorization and refer to the documentation provided at the following link: https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=getResetPasswordToken At this step, you will receive a resetToken, which will be used for the password reset process in Step 3. Step 3: Again, use the Token generated in Step 1(or generate a new one) for Authorization and follow the documentation provided at the following link: https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=resetPassword (edited)
Thanks Anmol Srivastava
To offer an alternative, you can also bridge the current API gap using OCAPI hooks.
https://github.com/SalesforceCommerceCloud/ocapi_hooks_collection shows how to do this.
dw.ocapi.shop.customers.password_reset.afterPOSTto send a password reset email.dw.ocapi.shop.auth.beforePOSTto accept the reset token and attempt to set the users password.You can review the tests for the basic flow:
https://github.com/SalesforceCommerceCloud/ocapi_hooks_collection/blob/main/test/integration/ocapi/04_passwordReset.js
I’m going to leave this issue open until we’ve resolved it in the default generated PWA.
Hi @stm-dschulz! This is a known issue/gap that the SLAS password reset flow currently doesn’t work in the PWA.
My understanding is that the SLAS password reset endpoint (
/customers/password/actions/create-reset-token?siteId={{site_id}}) doesn’t support shopper JWT. This endpoint is for admins to reset password on behalf of shoppers.I believe SLAS team is actively working on this issue. For now, if you need to implement this feature, you need to create a server side endpoint that grabs AM OAuth token, call the endpoint and create a password reset token, then you use that token to reset password using another endpoint
/reset.