Skip to content

Add Full REST API Support for “Login as Customer” Flow (secret-based impersonation) #40319

@mohaelmrabet

Description

@mohaelmrabet

Description

The existing Login as Customer feature in Magento relies on the Admin UI and a frontend redirect flow.
Currently, Magento generates a secret, injects it into a storefront URL, and the storefront exchanges this secret for a customer impersonation access token.

In headless, API-only, mobile, or decoupled frontend architectures, this native flow is not usable because there is no REST API endpoint to reproduce the same behavior.

This issue proposes extending Magento with an official REST implementation of the Login-as-Customer flow, preserving all security rules, auditing, ACLs, and token generation logic, while making the feature usable in modern API-driven environments.

Expected behavior

A dedicated REST API is available to:

  • Generate a Login-as-Customer secret
  • Validate it
  • Exchange it for a customer impersonation access token

The REST behavior matches the core feature, including:

  • ACL enforcement (Magento_LoginAsCustomer::token)
  • Secret expiration and validation rules

No dependency on the traditional storefront redirect flow.

Benefits

Enables headless, PWA, mobile apps, and backend systems to use Login-as-Customer safely.

Aligns with Magento’s API-first strategy consistently.

Removes the need for custom implementations in API-driven projects.

Creates a unified flow across Admin UI and REST, reducing integration complexity.

Additional information

This proposal does not change the existing Admin UI flow; it only exposes an equivalent REST option.

REST endpoints must implement the exact same security checks as the current controller-based implementation.

A draft PR is already being explored on our side, but feedback from maintainers on design, naming, and security considerations would be helpful.
#40310

Release note

Added support for performing “Login as Customer” through REST APIs, enabling headless and API-only applications to securely impersonate customers using the same secret-based flow as the Admin UI.

Metadata

Metadata

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions