data-src=../../includes/saas-only.md

User authentication

User authentication enables Commerce administrators to authenticate through Adobe's Identity Management System (IMS). This authentication flow is specifically designed for scenarios where API operations need to be executed with user-specific permissions. When using this method, all API calls are performed within the context of the authenticated admin user's permissions, as defined in the Adobe Admin Console.

Adobe provides three types of OAuth credentials for User Authentication with different application architectures:

  1. OAuth Web App: For applications with a backend server that can securely store client secrets
  2. OAuth Single Page App (SPA): For browser-based JavaScript applications
  3. OAuth Native App: For device-native applications (iOS, Android, desktop)

Each credential type has specific security considerations and implementation requirements. For detailed implementation guidance, see the User Authentication Guide.

Prerequisites

Before implementing user authentication, ensure you have:

Implementation steps

The user authentication flow consists of the following steps.

Step 1. Generate IMS credentials

To begin the implementation, you need to obtain IMS client credentials through the Adobe Developer Console. This process involves creating a new project and configuring OAuth authentication specifically for Adobe Commerce with Adobe ID integration.

The Adobe Developer Console provides a straightforward workflow:

Step 2. Authorization flow

Building authorization URL

The authorization URL is used to initiate the authentication process. It includes the client ID, redirect URI, scopes, and a state parameter for security. Here is the example for a web app:

https://ims-na1.adobelogin.com/ims/authorize/v2?client_id={{client_id}}&redirect_uri={{redirect_uri}}&scope={{scopes}}&state=something&response_type=code

Replace the following placeholders with your values:

Handling authorization response

Redirect handling:

  1. User completes authentication
  2. Browser redirects to your redirect_uri
  3. Authorization code is included in URL parameters

Authorization code extraction:

  1. Parse code from URL: ?code={{auth_code}}&state=something
  2. Verify state parameter matches original request

Error handling:

  1. Check for error parameters in redirect
  2. Implement appropriate error messaging
  3. Provide retry mechanisms

Step 3. Token exchange

Authorization code to access token:

  1. Make a POST request to the token endpoint.

    Request:

    POST https://ims-na1.adobelogin.com/ims/token/v3
    Authorization: Basic {{base64(client_id:client_secret)}}
    Content-Type: application/x-www-form-urlencoded
    
    code={{auth_code}}&grant_type=authorization_code
    

    Response:

    {
     "access_token": "{ACCESS_TOKEN}",
     "refresh_token": "{REFRESH_TOKEN}",
     "sub": "A0BC123D4CD449CA0A494133@a12b34cd5b5b7e0e0a494004",
     "id_token": "{ID_TOKEN}",
     "token_type": "bearer",
     "expires_in": 86399
     }
    

Token storage best practices

Usage examples

Here is a real-world example of making an authenticated API request after obtaining an access token:

GET /V1/products
Authorization: Bearer <access_token>

Troubleshooting

This section provides guidance on common issues and their resolutions when implementing user authentication.

Error handling

Token refresh flow