We’re using the Storefront API for our shop. Customers login to the storefront using the customerAccessTokenCreate mutation. We then associate the checkout with the customer using the checkoutCustomerAssociateV2 mutation. However when we direct the user to the web checkout, they’re not authenticated.
If they click the login link, they’re taken to the custom domain login page where they can authenticate using the themes engine store. This is not ideal as they have to authenticate twice.
From spelunking through the forums and various Github issues, this appears to be the case because of valid security concerns. Is this still the case?
I am also unsure what’s the purpose of checkoutCustomerAssociateV2 and customerAccessTokenCreate if when you come to the most important part of most shops: the checkout, you’re asked to login again.
What’s the recommended implementation for the Storefront API? Should we be using the Themes Engine for all authenticated views (account management, etc) and only use it to build the Storefront API to build the anonymous parts of our storefront?
We came to the conclusion that we mainly cared about a headless storefront and less so about account management and authentication. Our solution without Multipass was to use the theme for authentication and account management.
Elevar built a headless site for StriVectin like this and there’s a public write up here:
We have the Shopify store on a sub domain of our headless site so that we can share cookies for analytics and we also set an “authenticated” cookie from the themes engine to tweak menus on our storefront and pass to analytics. We have a minimal theme with a redirect to our headless site for shop URLs. We use a JS redirect in the head (required to pass query string params as Liquid doesn’t have access to them), head meta redirect fallback after the JS (no query string params) and finally a 500ms delayed with css user message with redirect link in case those both fail. It’s actually rather seamless experience.
A lot of the Shopify and App Store ecosystem make assumptions about shop URLs so the added advantage of the redirects theme is that product page URLs that assume you use the theme still work. We’re also using ReCharge and it was a pain to work with their account subscription management APIs with a headless site so this method allows us to just use their out of the box account management.
Using Multipass implies that you have a separate users database and authentication system, which is not necessarily the case if you just have a statically generated storefront built with the storefront API. Using the checkout workflow, you can use checkoutShippingAddressUpdateV2 to pass customer details to the checkout so a customer with a valid access token can hit step 2 of the checkout immediately. They are still not “logged in” though. Additionally, with the release of the cart workflow, which is required for subscriptions, there is no mechanism to do that (see open GitHub issue).
Hi,
We’ve developed a frontend web app using Storefront API.
We can do user registration, login, etc but we cannot create an authenticated checkout.
When user is logged in in our web app, appears not logged in the checkout, but when the order is complete it’s associated to the user.
We’ve tried both “cartCreate” and “checkoutCreate” APIs.
With “cartCreate” API we cannot assign “deliveryAddressPreferences” to the “CartBuyerIdentity”.
We tried also with “cartBuyerIdentityUpdate” but it didn’t work.
With “checkoutCreate” instead we can send the shipping address to the checkout and when the user arrive to the chekout the address is filled.
With “checkoutCustomerAssociateV2” we associate the user to the checkout object but the user is stil not logged in the checkout page.
Are there any solutions?
Is it possible to create a logout where the user is logged in, if we login with Storefront API?
If you use the checkout API you can use checkoutShippingAddressUpdateV2 so at least the user does not have to enter their address again. They are still not authenticated in this case, however.
With cart API there is no way to do it other than passing the address fields in a URL query string to the checkout.
Unfortunately, considering how much Shopify is pushing headless commerce and the storefront API, there are some serious gaps. It should be at parity with liquid and any features that are added to liquid should also be available on the storefront API.
Is this 100% confirmed? If so, I’m not worried about them being authenticated. Like you, I have them automatically going to step 2 of the checkout process. As long as the user’s order is properly attached to the contact email, I think I can live with that. It’s not ideal having the login link listed but I believe that can be removed.