Shopifex.Plug.ShopifyApiAuth (Shopifex v3.0.0)

Copy Markdown View Source

Authenticates async API requests from an embedded SPA front end using the Shopify App Bridge session token.

The front end attaches the token Shopify gives it (via app-bridge's getSessionToken/idToken) as an Authorization: Bearer <token> header. This plug verifies it with Shopifex.SessionToken, resolves the shop, and builds the Shopifex session so controllers can call Shopifex.Plug.current_shop/1.

On failure it responds 401, halts, and sets the x-shopify-retry-invalid-session-request: 1 response header. Embedded session tokens live only ~60 seconds, so an in-flight or back-forward-cache request routinely arrives with an expired token; App Bridge's authenticatedFetch watches for that header and transparently retries the request with a freshly minted id_token instead of surfacing the 401 to the user.

Used by the :shopify_api / :shopifex_api pipelines. Replaces the Guardian-based pipeline used in Shopifex v2.

Summary

Functions

call(conn, opts)

init(opts)