Skip to content

Commit 63dc33a

Browse files
authored
Merge pull request #461 from andimov/fix-accs-api
Update authentication section to clarify OAuth Authorization flows
2 parents a977262 + ca4b4e1 commit 63dc33a

File tree

4 files changed

+173
-430
lines changed

4 files changed

+173
-430
lines changed

src/data/navigation/sections/rest.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ module.exports = [
2727
title: "Introduction",
2828
path: "/rest/authentication/"
2929
},
30+
{
31+
title: "Server-to-server authentication",
32+
path: "/rest/authentication/server-to-server.md",
33+
},
3034
{
3135
title: "User authentication",
3236
path: "/rest/authentication/user.md",
3337
},
34-
{
35-
title: "Server-to-server authentication",
36-
path: "/rest/authentication/server-to-server.md",
37-
}
3838
],
3939
},
4040
{
Lines changed: 49 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,158 +1,79 @@
11
---
22
title: Authentication in Adobe Commerce as a Cloud Service
3-
description: Generate the IMS access token for admin user.
3+
description: Learn about REST API authentication in Adobe Commerce as a Cloud Service.
44
edition: saas
55
keywords:
66
- REST
77
- Integration
8-
---
9-
10-
# Authentication in Adobe Commerce as a Cloud Service
11-
12-
In Adobe Commerce as a Cloud Service (SaaS), you must use Adobe's Identity Management Service (IMS) for admin authentication. The traditional admin token generation method is not supported in SaaS environments. Instead, you must obtain an IMS admin token through OAuth authentication.
13-
14-
This authentication method ensures that all API calls are performed within the context of the authenticated admin user's permissions, as defined in the ACCS.
15-
16-
<InlineAlert variant="note" slots="text"/>
17-
18-
See [Authentication](../../get-started/authentication/index.md) in the _Get Started_ guide for information about the authentication methods available on other versions of Adobe Commerce.
19-
20-
## Authentication Options for Adobe Commerce as a Cloud Service
21-
22-
Adobe Commerce as a Cloud Service (ACCS) supports two primary authentication methods for admin-level API access:
23-
24-
- **User authentication (IMS)** - Use this method when you need to authenticate on behalf of a specific admin user with user-specific permissions. This page covers the user authentication flow.
25-
26-
- **Server-to-server integration** - Use this method for automated system-to-system communication without user intervention. For detailed instructions on setting up server-to-server integration, see [Create server-to-server integration](server-to-server.md).
27-
28-
## Security best practices
29-
30-
- Store tokens securely using encryption at rest.
31-
- Implement proper token rotation procedures.
32-
- Monitor token expiration and implement automatic refresh.
33-
- Use HTTPS for all authentication requests.
34-
- Validate state parameters to prevent CSRF attacks.
35-
36-
## Generate an IMS access token
37-
38-
Before implementing IMS authentication, ensure you have:
39-
40-
- An active Adobe Commerce as a Cloud Service license.
41-
- Access to Adobe Developer Console for creating OAuth credentials.
42-
- A configured redirect URI where users will return after authentication.
43-
- A secure environment for token handling.
44-
45-
### Step 1: Generate IMS credentials
46-
47-
1. Navigate to Adobe Developer Console.
48-
1. Create or select a project that will house your authentication credentials.
49-
1. Add the **Adobe Commerce with Adobe ID** API to your project.
50-
1. Select your preferred OAuth 2 authentication type:
51-
- **Web App**: For applications with a backend server that can securely store client secrets
52-
- **Single-Page App (SPA)**: For browser-based JavaScript applications
53-
- **Native App**: For device-native applications (iOS, Android, desktop)
54-
1. Configure the allowed redirect URIs.
55-
1. Copy the client ID and client secret.
56-
1. Securely save your credentials.
57-
58-
### Step 2: Implement the authorization flow and response
59-
60-
To authenticate a user and obtain an authorization code, follow these steps:
61-
62-
1. Create an authorization URL to initiate the authentication process. The URL has the following format:
63-
64-
```http
65-
https://ims-na1.adobelogin.com/ims/authorize/v2?client_id={{client_id}}&redirect_uri={{redirect_uri}}&scope={{scopes}}&state=something&response_type=code
66-
```
67-
68-
Replace the placeholders with your values:
69-
70-
- `{{client_id}}`: Your IMS client ID
71-
- `{{redirect_uri}}`: Your configured redirect URI
72-
- `{{scopes}}`: A comma-separated list of required scopes, such as `AdobeID,openid,email,profile,additional_info.roles,additional_info.projectedProductContext`
73-
74-
1. Handle the authorization response. When the user completes authentication through Adobe's login interface, the browser redirects to your `redirect_uri`. The authorization code is included in URL parameters:
75-
76-
`?code={{auth_code}}&state=something`
77-
78-
Extract the authorization code and verify the state parameter
79-
80-
### Step 3: Exchange the authorization code for an access token
81-
82-
Make a POST request to exchange the authorization code for an access token:
8+
---
839

84-
**Endpoint:**
10+
# REST Authentication in Adobe Commerce as a Cloud Service
8511

86-
`POST https://ims-na1.adobelogin.com/ims/token/v3`
12+
Adobe Commerce as a Cloud Service REST API authentication is handled through Adobe's Identity Management System (IMS) through standardized OAuth 2 protocols. This authentication system supports both interactive user-based workflows and automated server-to-server integrations, ensuring secure and appropriate access for different use cases. The traditional admin and integration token generation methods is not supported in SaaS environments. Instead, you must obtain an IMS admin token through OAuth authentication.
8713

88-
**Headers:**
14+
The following types of authentication are available for Adobe Commerce as a Cloud Service REST APIs:
8915

90-
```text
91-
Authorization: Basic {{base64(client_id:client_secret)}}
92-
Content-Type: application/x-www-form-urlencoded
93-
```
16+
- [Server-to-server authentication](#server-to-server-authentication) - Choose this flow for automated, system-to-system integrations that do not require user interaction, such as background jobs, integrations, and scripts.
9417

95-
**Payload:**
18+
- [User authentication](#user-authentication) - Choose this flow when API operations must be performed by an admin user according to their permissions, such as when actions must be attributed to a specific admin user.
9619

97-
```text
98-
code={{auth_code}}&grant_type=authorization_code
99-
```
20+
See [Authentication](../../get-started/authentication/index.md) in the _Get Started_ guide for information about the authentication methods available on other versions of Adobe Commerce.
10021

101-
**Response:**
22+
## Server-to-server authentication
10223

103-
```json
104-
{
105-
"access_token": "{ACCESS_TOKEN}",
106-
"refresh_token": "{REFRESH_TOKEN}",
107-
"sub": "A0BC123D4CD449CA0A494133@a12b34cd5b5b7e0e0a494004",
108-
"id_token": "{ID_TOKEN}",
109-
"token_type": "bearer",
110-
"expires_in": 86399
111-
}
112-
```
24+
Server-to-server authentication enables automated systems to interact with Commerce APIs without user intervention. This method uses technical account credentials to obtain access tokens directly, making it perfect for background processes, scheduled tasks, and system integrations that need to operate independently.
11325

114-
### Step 4: Use the access token
26+
Key benefits of this approach include:
11527

116-
Use the access token in the Authorization header for all Commerce REST API calls, such as retrieving a list of products.
28+
- Non-interactive authentication for automated processes
29+
- Obtain a new access token as needed using client credentials
30+
- Ideal for headless and backend integrations
31+
- Support for system-wide permissions and access control
11732

118-
**Endpoint:**
33+
For detailed steps, see the [server-to-server Authentication Guide](./server-to-server.md).
11934

120-
`GET https://<server>.api.commerce.adobe.com/<tenant-id>/v1/products`
35+
## User authentication
12136

122-
**Headers:**
37+
The user authentication flow provides a secure, OAuth-based workflow where users authenticate through Adobe IMS, ensuring credentials are never directly handled by your application.
12338

124-
```text
125-
Authorization: Bearer {ACCESS_TOKEN}
126-
```
39+
Key benefits of this approach include:
12740

128-
## Token refresh
41+
- Direct integration with Adobe's secure authentication interface
42+
- Automatic handling of user permissions based on Adobe Commerce Admin role
43+
- Support for interactive workflows in admin applications
44+
- Token refresh capabilities for extended sessions
45+
- Compliance with OAuth 2 security standards
12946

130-
Access tokens expire after a certain period (typically 24 hours). Use the refresh token to obtain a new access token:
47+
For detailed steps, see the [User Authentication Guide](./user.md).
13148

132-
**Endpoint:**
49+
## Getting started
13350

134-
`POST https://ims-na1.adobelogin.com/ims/token/v3`
51+
The following concepts apply to both authentication flows and are important for successful integration:
13552

136-
**Headers:**
53+
- Prerequisites:
54+
- Adobe Commerce as a Cloud Service license
55+
- Adobe Developer Console access
56+
- Understanding of OAuth 2
57+
- Environment preparation:
58+
- Development environment
59+
- Adobe Developer Console project configuration
60+
- API testing tools
13761

138-
```text
139-
Authorization: Basic {{base64(client_id:client_secret)}}
140-
Content-Type: application/x-www-form-urlencoded
141-
```
62+
## Access tokens
14263

143-
**Payload:**
64+
- Use the bearer token type for API authorization
65+
- Include your access token in the Authorization header of REST API requests
66+
- Familiarize yourself with token lifecycle management and renewal processes
67+
- Review security considerations and best practices for token storage
14468

145-
```json
146-
grant_type=refresh_token&refresh_token={{refresh_token}}
147-
```
69+
## Scopes
14870

149-
**Response:**
71+
The following permission scopes are required for Adobe Commerce as a Cloud Service REST API access:
15072

151-
```json
152-
{
153-
"access_token": "{ACCESS_TOKEN}",
154-
"refresh_token": "{REFRESH_TOKEN}",
155-
"expires_in": 86399,
156-
"token_type": "bearer"
157-
}
158-
```
73+
- `AdobeID`
74+
- `openid`
75+
- `email`
76+
- `profile`
77+
- `additional_info.roles`
78+
- `additional_info.projectedProductContext`
79+
- `commerce.accs`

src/pages/rest/authentication/server-to-server.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
---
2-
title: Create server-to-server integration
2+
title: Server-to-server Authentication
33
description: Learn how to set up OAuth server-to-server authentication for Adobe Commerce as a Cloud Service REST API
44
edition: saas
55
keywords:
66
- REST
77
- Integration
88
---
99

10-
# Create server-to-server integration
10+
# Server-to-server Authentication
1111

12-
This guide provides practical steps for implementing server-to-server integration with Adobe Commerce as a Cloud Service REST APIs using OAuth server-to-server authentication. This type of integration enables automated system-to-system communication without user intervention, which is ideal for the following use cases:
12+
This guide provides practical steps for implementing integration with Adobe Commerce as a Cloud Service REST APIs using OAuth 2 server-to-server authentication. This type of integration enables automated communication without user intervention, which is ideal for the following use cases:
1313

1414
- Background processes and automated tasks
1515
- Data synchronization services
1616
- Automated reporting systems
17-
- Microservices architecture integration
1817

1918
## Prerequisites
2019

@@ -53,7 +52,7 @@ Use the following steps to implement server-to-server integration with Adobe Com
5352

5453
### Step 2: Implement token generation
5554

56-
To authenticate with the Adobe Commerce as a Cloud Service REST APIs, you need to generate an IMS access token using your client credentials. This token is used to authorize API requests.
55+
To authenticate with the Adobe Commerce as a Cloud Service REST APIs, you need to generate an IMS access token using your client credentials. This token is used to authorize API requests. **Be sure to include the `commerce.accs` scope.**
5756

5857
```javascript
5958
// tokenManager.js
@@ -89,7 +88,7 @@ class TokenManager {
8988
client_id: process.env.IMS_CLIENT_ID,
9089
client_secret: process.env.IMS_CLIENT_SECRET,
9190
grant_type: 'client_credentials',
92-
scope: 'openid,AdobeID,email,profile,additional_info.roles,additional_info.projectedProductContext' // required scopes
91+
scope: 'openid,AdobeID,email,profile,additional_info.roles,additional_info.projectedProductContext,commerce.accs' // required scopes
9392
})
9493
});
9594
@@ -168,9 +167,9 @@ class ACCSApiClient {
168167
module.exports = ACCSApiClient;
169168
```
170169
171-
### Step 4: Usage example
170+
### Usage example
172171
173-
The following example implementation demonstrates how to use the API client.
172+
Here is a real-world example of making an authenticated API request after obtaining an access token:
174173
175174
```javascript
176175
// example-usage.js
@@ -198,7 +197,7 @@ main();
198197
199198
## Best practices
200199
201-
The following best practices help ensure your server-to-server integration is secure, efficient, and maintainable.
200+
The following best practices tips help ensure your server-to-server integration is secure, efficient, and maintainable.
202201
203202
### Security
204203
@@ -220,7 +219,7 @@ The following best practices help ensure your server-to-server integration is se
220219
221220
## Alternative implementations
222221
223-
The following example shows how to implement server-to-server integration using Python.
222+
The following example shows how to implement server-to-server integration using Python. **Be sure to include the `commerce.accs` scope.**
224223

225224
```python
226225
import os
@@ -256,7 +255,7 @@ class ACCSTokenManager:
256255
'client_id': self.client_id,
257256
'client_secret': self.client_secret,
258257
'grant_type': 'client_credentials',
259-
'scope': 'openid,AdobeID,email,profile,additional_info.roles,additional_info.projectedProductContext'
258+
'scope': 'openid,AdobeID,email,profile,additional_info.roles,additional_info.projectedProductContext,commerce.accs'
260259
}
261260
262261
try:
@@ -325,5 +324,5 @@ If you encounter issues during implementation, consider the following troublesho
325324
### Token Generation Fails
326325

327326
- Verify your client ID and secret are valid
328-
- Check that your OAuth Server-to-Server credentials are properly configured
327+
- Check that your OAuth server-to-server credentials are properly configured
329328
- Ensure you're using the correct IMS endpoint

0 commit comments

Comments
 (0)