Skip to main content

Require Login API

The Require Login API lets your extension prompt pre-authenticated buyers to log in on the Order status page. Use this API to gate sensitive content and actions behind full authentication by calling the requireLogin() function.

This API is available only on the Order status page. It isn't available on other customer account extension targets.

  • Gate sensitive information: Prompt the buyer to sign in before showing detailed order data, account-specific actions, or personalized content.
  • Enforce authentication for actions: Require sign-in before allowing the buyer to perform actions like initiating a return or updating their address.

The shopify global object provides the login prompt method. Call requireLogin() on shopify to trigger a login prompt for pre-authenticated buyers.

Anchor to requireLogin
requireLogin
() => Promise<void>
required

Triggers a login prompt if the customer is viewing a pre-authenticated Order status page. Use this to require full authentication before displaying sensitive information in your extension.

Triggers a login prompt for pre-authenticated buyers. Doesn't guarantee the buyer completes the login. Handle the dismissal case in your code.


  • Check authentication state first: Use the Authentication State API to check if the buyer is pre_authenticated before calling requireLogin(). Calling it on an already authenticated buyer has no effect.
  • Use for sensitive content: Only prompt for sign-in when your extension needs to display information that requires full authentication, such as detailed customer data or account-specific actions.
  • Handle dismissal gracefully: requireLogin() triggers a login prompt but doesn't guarantee the buyer completes it. Handle the case where the buyer dismisses the prompt.

Was this page helpful?