All things Shopify and commerce
I've implemented the steps here to log a user into our Headless Storefront via the new customer account Authentication.
It suggests that in order for the user to then be logged in at the checkout page, I only need to redirect to the checkout page with `logged_in=true`.
This doesn't seem to work. Has anyone gotten this to work?
-Make sure that New Customer Accounts are enabled in the Shopify Settings.
Do you have any errors?
CORS issues?
Running the site with a domain or local server?
Back when I did this with Next.js I remember making a reusable component
import { useRouter } from 'next/router';
import { useEffect } from 'react';
const RedirectComponent = () => {
const router = useRouter();
useEffect(() => {
const handleRouteChange = (url) => {
// Check if the URL contains the specific domain
if (url.includes('littlepaintingprints.myshopify.com')) {
// Redirect to the desired URL
window.location.href = 'https://littlepaintingprints.com/checkouts/<checkout_id>?logged_in=true';
}
};
It was something like that. I need more coffee and sleep right now, sorry this is all the help I have.
Hey BeauxBreaux - thanks for the response!
I do have the new customer accounts toggled in settings. I'm able to successfully login and logout.
For login, the flow is as follows:
1. User navigates to login page at mydomain.com/signin
2. Server redirects to the authorization url (shopify.com)
3. User enters email, and submits code from their email client
4. User is navigated back to mydomain.com where i exchange the `code` for id/access/refresh tokens.
I'm also appending `logged_in=true` to the checkout URL as specified in the docs. However, the login link still exists in the checkout page, and clicking it immediately authenticates the user. But, the expected behavior should not require user interaction.
Regarding CORS, I don't think this is applicable as there are no front end AJAX calls crossing domains at play. the OAuth2 flow is all first party redirects.
In terms of other errors, not really. The checkout url (
im having the same issue. have you found a solution for this yet?
For me it was making sure "Login links" were enabled. Also it seemed like the `?logged_in=true` didn't make a difference; the user is authenticated at checkout with or without that.
Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024The Hydrogen Visual Editor is now available to merchants in Shopify Editions | Summer '...
By JasonH Sep 2, 2024Note: Customizing your CSS requires some familiarity with CSS and HTML. Before you cust...
By JasonH Aug 12, 2024