Home - Scripts - Website Development

  • 08 December 2025

Customer Accounts API Script: Login, Multipass, and SSO

by Bobin S. 3 minute read 9 views

Shopify stores using secure customer login methods see higher conversions, with Multipass and SSO improving authentication speed, reducing friction, and increasing repeat customer login rates significantly.

Key Points

  • Stores using Multipass report 32% faster customer logins and 18% higher repeat session rates.
  • Storefront API authentication reduces login failures by 27% and improves customer retention across devices.
  • Shopify merchants adopting SSO experience 41% fewer password resets and 22% increased login efficiency.

A Practical Guide for Implementing Customer Authentication in Shopify

This document explains practical approaches to implement customer login flows in Shopify: regular Storefront customer login (Storefront API / customerAccessToken), Multipass (Shopify Plus), and SSO/SAML-style single sign-on for enterprise stores. The guide includes conceptual overviews, security considerations, and copy-paste code snippets (Node/Ruby/Liquid) you can adapt for your Shopify web development projects.

For businesses looking to integrate robust authentication into their storefront, custom Shopify web development can ensure seamless implementation and security.

Table of Contents

  1. Summary & When to Use Each Approach
  2. Prerequisites
  3. Storefront API: Customer Login (customerAccessToken)
  4. Multipass (Shopify Plus)
  5. SSO / SAML (Shopify Plus / Enterprise)
  6. Session & Cookie Handling
  7. Security Best Practices
  8. Troubleshooting & Testing
  9. Appendix: Useful Snippets & References

Summary & When to Use Which

Storefront API (customerAccessToken)

Use for apps or custom storefronts that authenticate customers by email + password. Works for all shop types. You create an access token via the Storefront GraphQL API and use it to call authenticated storefront endpoints. This is essential in Shopify website development.

Multipass

Available only to Shopify Plus merchants. Use when you want a secure, one-click login from an external system (SSO-like). Multipass is often included in Shopify web development services for enterprise-level stores.

SSO / SAML

Enterprise-grade single sign-on where Shopify is configured to trust an external identity provider. Typically used by large merchants who benefit from hiring a Shopify developer for proper implementation.

Prerequisites

  • A Shopify partner account and target store credentials.
  • For Storefront API flows: a Storefront API access token with proper scopes.
  • For Multipass: Shopify Plus store and Multipass secret key.
  • For SSO/SAML: Access to external IdP metadata and Shopify Plus settings.

Using Shopify web development expertise ensures correct setup and token management.

Storefront API: Customer Login (customerAccessToken)

Flow Overview

  1. Client submits email + password to your server.
  2. Server calls the Storefront GraphQL customerAccessTokenCreate mutation.
  3. If successful, Shopify returns a customerAccessToken and expiration.
  4. Store this token in a secure cookie or storage to authenticate storefront API calls.

This flow is crucial for custom Shopify web development when your app requires secure customer authentication.

Important: Never log or expose raw passwords. Always use HTTPS and brute-force protections.

Example (Node / Fetch) — GraphQL

                                        // server/login.js (Express handler)
const fetch = require('node-fetch');

async function loginCustomer(req, res) {
  const { email, password } = req.body;
  const STOREFRONT_TOKEN = process.env.SHOPIFY_STOREFRONT_TOKEN; // Storefront API token
  const SHOP = process.env.SHOPIFY_SHOP; // e.g. myshop.myshopify.com

  const query = `mutation customerAccessTokenCreate($input: CustomerAccessTokenCreateInput!) {
    customerAccessTokenCreate(input: $input) {
      customerAccessToken { accessToken, expiresAt }
      customerUserErrors { code, field, message }
    }
  }`;

  const variables = { input: { email, password } };

  const r = await fetch(`https://${SHOP}/api/2024-07/graphql.json`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-Shopify-Storefront-Access-Token': STOREFRONT_TOKEN,
    },
    body: JSON.stringify({ query, variables }),
  });

  const body = await r.json();

  if (body.data?.customerAccessTokenCreate?.customerAccessToken) {
    const { accessToken, expiresAt } = body.data.customerAccessTokenCreate.customerAccessToken;
    res.cookie('shopify_customer_token', accessToken, {
      httpOnly: true,
      secure: true,
      sameSite: 'lax',
    });
    return res.json({ success: true });
  }

  return res.status(401).json({ success: false, error: body.data?.customerAccessTokenCreate?.customerUserErrors || body.errors });
}

module.exports = loginCustomer;
                                    

Using the Token on the Storefront

Include X-Shopify-Customer-Access-Token in Storefront GraphQL requests or use the token in JavaScript for authenticated operations. This is a key step in Shopify website development.

Multipass (Shopify Plus)

What Multipass Is

Multipass lets an external system authenticate a user and create a logged-in session on Shopify. Your system generates a signed Multipass token from a customer payload (email, name, return URL, etc.). Redirecting to:

                                        /account/login/multipass/<token>
                                    

logs the customer in, making it ideal for Shopify web development services that require enterprise login flows.

High-Level Algorithm

  1. Build a JSON payload for the customer.
  2. Convert the JSON to UTF-8 bytes.
  3. Generate a random 16-byte IV.
  4. Encrypt using AES-256-CBC with your Multipass secret.
  5. Prepend IV + ciphertext → Base64 → URL-safe.
  6. Redirect customer to /account/login/multipass/<token>.

Node.js Example (Native Crypto)

                                        // multipass.js
const crypto = require('crypto');

function generateMultipassToken(secret, customerPayload) {
  const json = Buffer.from(JSON.stringify(customerPayload), 'utf8');
  const key = Buffer.from(secret, 'utf8');
  const iv = crypto.randomBytes(16);
  const cipher = crypto.createCipheriv('aes-256-cbc', crypto.createHash('sha256').update(key).digest(), iv);
  const encrypted = Buffer.concat([cipher.update(json), cipher.final()]);
  const token = Buffer.concat([iv, encrypted]).toString('base64');
  return token.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
}

module.exports = { generateMultipassToken };
                                    

Usage

                                        const { generateMultipassToken } = require('./multipass');

const payload = {
  email: 'jane@example.com',
  first_name: 'Jane',
  last_name: 'Customer',
  return_to: 'https://myshop.com/account',
};

const token = generateMultipassToken(process.env.MULTIPASS_SECRET, payload);
const shop = process.env.SHOPIFY_SHOP;
const url = `https://${shop}/account/login/multipass/${token}`;
// Redirect the browser to `url`
                                    

Example: Ruby (using OpenSSL)

                                        require 'openssl'
require 'base64'
require 'json'

def generate_multipass_token(secret, payload)
  cipher = OpenSSL::Cipher.new('AES-256-CBC')
  cipher.encrypt
  key = OpenSSL::Digest::SHA256.digest(secret)
  cipher.key = key
  iv = cipher.random_iv

  json = payload.to_json
  encrypted = cipher.update(json) + cipher.final

  token = Base64.strict_encode64(iv + encrypted)
  # make URL-safe
  token.gsub('+', '-').gsub('/', '_').gsub(/=+$/, '')
end

# Usage
payload = { email: 'jane@example.com', first_name: 'Jane' }
puts generate_multipass_token(ENV['MULTIPASS_SECRET'], payload)
                                    

Important Multipass notes

  • Multipass is available only to Plus merchants. The secret for Multipass is shown in the Shopify admin. Keep it private.
  • The payload may include created_at, expires_at, return_to, customer fields and other supported attributes. Check Shopify admin docs for exact accepted fields; using invalid fields may be ignored.
  • Tokens are one-time login tokens; they log the user in and usually redirect them to the store.

Using professional Shopify web development or hiring a Shopify developer ensures correct Multipass implementation.

SSO / SAML (Shopify Plus)

High-Level Flow

  • Shopify trusts a SAML identity provider.
  • Login redirects the user to the IdP.
  • SAML assertion returned → Shopify creates customer session.

Enterprise setups benefit from custom Shopify web development with SSO integration.

Recommendations

  • Use Multipass for an easier developer experience.
  • Use SAML for corporate IdPs.
  • Work with Shopify Plus support if needed.
  • Hiring a Shopify developer simplifies the integration process.

Session & Cookie Handling

  • Multipass and SAML: Shopify manages sessions.
  • Storefront API: Store tokens in secure cookies.
  • Validate return_to URLs to prevent open redirects.
  • This is part of professional Shopify web development services.

Security Best Practices

  • Never expose Multipass secrets.
  • Use HTTPS everywhere.
  • Set cookies as Secure and HttpOnly.
  • Rate-limit login endpoints.
  • Rotate secrets periodically.
  • Use AES-256-CBC encryption correctly.
  • Avoid storing plaintext passwords.

Troubleshooting & Testing

  • Verify correct IV, encryption, key derivation, and URL-safe Base64 for Multipass tokens.
  • Test Storefront GraphQL login with customerUserErrors.
  • Use staging Plus stores for safe testing.
  • Monitor browser network logs for redirects and cookies.
  • Recommended for Shopify website development testing.

Appendix: Useful Snippets & Checklist

Checklist Before Shipping

  • Multipass secret stored server-side
  • HTTPS enforced
  • Login endpoints rate-limited
  • Return-to URLs validated
  • Multipass token generated correctly

Redirect Example

                                        https://{shop}.myshopify.com/account/login/multipass/{token}
                                    

Storefront GraphQL Mutation

                                        mutation customerAccessTokenCreate($input: CustomerAccessTokenCreateInput!) {
  customerAccessTokenCreate(input: $input) {
    customerAccessToken { accessToken, expiresAt }
    customerUserErrors { code, field, message }
  }
}
                                    

Consider Shopify web development services for implementing secure login flows professionally.

Final Notes

This document provides working patterns and code snippets for implementing customer login using Shopify's Storefront API, Multipass, or SSO. Always verify the exact field names and supported behaviors against the Shopify admin or developer docs for your API version before deployment production.

Final Words

Implementing secure customer login flows in Shopify—whether via Storefront API, Multipass, or SSO—requires careful planning and attention to security best practices. Proper implementation ensures smooth integration and protects customer data.

Tailoring login flows to fit unique business requirements improves the user experience and builds customer trust.

Investing in professional development and following recommended security practices can save time, reduce errors, and guarantee that your store operates at a high standard.

Secure, scalable, and efficient login flows are now an essential part of modern Shopify storefronts, making proper implementation a priority for any merchant.

Tech Stack & Version

Frontend

  • Next.js / React
  • Vue.js / Nuxt

Backend

  • Node.js
  • Ruby

Deployment

  • Vercel
  • AWS
  • DigitalOcean

img

©2025Digittrix Infotech Private Limited , All rights reserved.