New Customer Accounts API for authentication at Checkout

New Customer Accounts API for authentication at Checkout

futbolpal
Shopify Partner
5 0 2

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?

Replies 4 (4)

beauxbreaux
Shopify Partner
245 18 42

-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. 

Beaux Barker
Developer
Hire me on Fiverr
futbolpal
Shopify Partner
5 0 2

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 (

Willd99
Shopify Partner
6 0 0

im having the same issue. have you found a solution for this yet?

codesound
Shopify Partner
1 0 0

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.  

 

Screenshot 2024-08-05 at 4.01.48 PM.png