Solved

[Storefront API] - Help using customerResetByUrl mutations

andrewrobbins
Shopify Partner
12 0 4

Hey everyone,

 

I'm looking for help in using the customerResetByUrl mutation on the Storefront API.

 

https://help.shopify.com/en/api/storefront-api/reference/mutation/customerresetbyurl

 

After a bit of debugging, I finally figured out that customerResetByUrl takes the default Shopify password reset URL, also known as the resetUrl. This is the same URL set within the password reset email template. However, I'm confused how this is expected to be used.

 

Is customerResetByUrl intended to be used programmatically? I'm trying to build the password reset flow on my own site without the user going to Shopify at all. So ideally, I'm trying to force the password reset link to point to my own server without modifying the email template. Is this possible?

 

It seems I have no way of accessing resetUrl via the API. The only place I see resetUrl is within the password reset email. There must be something I'm missing, otherwise how would you even use this mutation without access to resetUrl?

 

Any direction would be much appreciated!

Creator of ShopWP https://wpshop.io
Accepted Solution (1)
vix
Shopify Staff
540 103 121

This is an accepted solution.

Hey @andrewrobbins As i'm sure you know - the format of the URL is your-domain.com/account/reset/{{ customer-id }}/{{ reset-token }} at this time there is no way to pull this from the API, however, I will pass along your feedback with the use case. 

 

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 6 (6)

andrewrobbins
Shopify Partner
12 0 4

Really need some help here, any thoughts?

Creator of ShopWP https://wpshop.io
vix
Shopify Staff
540 103 121

Hi @andrewrobbins 

 

You are on the right track. In order to get the reset URL to point to your app you will need to modify the liquid template. Can I ask why you would like to avoid doing this? That way, you can redirect the customer to the proper link. 

 

The flow would be similar to the following: 

 

    1. customer recovers password via customerRecover mutation
    2. customerRecover mutation sends an email to them with reset instructions
    3. the email template is customized to redirect to their site, passing the id and reset token from liquid. You can use  customer.reset_password_url liquid variable.
    4. Then you are able to use the customerResetByUrl  mutation

 

To learn more visit the Shopify Help Center or the Community Blog.

andrewrobbins
Shopify Partner
12 0 4

Hey @vix 

 

Thanks for the response!

 

I'm doing exactly the steps you listed and it's working great as is.

 

The reason I'd like to eliminate the liquid modification step is because my app requires end users to make this tweak on their ownmany of whom are without any developer experience.

 

I could create a tutorial in my documentation, but it would really improve the UX flow of using my product if I could just handle it for them programmatically.

 

Perhaps an API endpoint that would allow me to filter the domain of the customer.reset_password_url value directly?

Creator of ShopWP https://wpshop.io
vix
Shopify Staff
540 103 121

This is an accepted solution.

Hey @andrewrobbins As i'm sure you know - the format of the URL is your-domain.com/account/reset/{{ customer-id }}/{{ reset-token }} at this time there is no way to pull this from the API, however, I will pass along your feedback with the use case. 

 

To learn more visit the Shopify Help Center or the Community Blog.

Juan_Menendez
Visitor
2 0 1

Hi there. Is there any update about this? I am facing now the same problem now

badb1
Shopify Partner
1 0 0

Hi Andrew,

 

Trying to get the customerRecover mutation working, I am trying with postman and for the life of me, I can't get it to work.

 

The error that I am getting is this :

Field 'customerRecover' doesn't exist on type 'Mutation'
And the mutation i use is :
mutation customerRecover($email: String!){
customerRecover(email: $email){
customerUserErrors{
code
message
}
userErrors {
message
}
}
}
 
Do you have any idea why does it not want to play ball ?