Skip to content

Commit d2ad6d5

Browse files
Adding documentation to reuse access tokens
1 parent 9c0c7f4 commit d2ad6d5

File tree

2 files changed

+47
-31
lines changed

2 files changed

+47
-31
lines changed

src/pages/guides/authentication/ServerToServerAuthentication/IMS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
Following is an API reference for Adobe Identity Management Services (IMS) APIs.
44

5+
- [Fetching access tokens](#fetching-access-tokens)
6+
- [Refreshing access tokens](#refreshing-access-tokens)
7+
- [List all client secrets](#list-all-client-secrets)
8+
- [Add client secret to credential](#add-client-secret-to-credential)
9+
- [Remove client secret from credential](#remove-client-secret-from-credential)
10+
11+
512
## Fetching access tokens
613

714
The OAuth Server-to-server credential uses the `client_credentials` grant to generate access tokens.

src/pages/guides/authentication/ServerToServerAuthentication/implementation.md

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ The following guide goes over finer implementation details for OAuth Server-to-S
55

66
On this page:
77
+ [Setting up the OAuth Server-to-Server credential](#setting-up-the-oauth-server-to-server-credential)
8-
+ [Generating access tokens using cURL](#generating-access-tokens-using-curl)
8+
+ [Generate access tokens](#generate-access-tokens)
9+
+ [Generating access tokens programmatically](#generating-access-tokens-programmatically)
910
+ [Generating access tokens using standard OAuth2 libraries](#generating-access-tokens-using-standard-oauth2-libraries)
1011
+ [Rotating client secrets](#rotating-client-secrets)
1112
+ [Rotating client secrets programmatically](#rotating-client-secrets-programmatically)
@@ -37,13 +38,21 @@ The product profile selection works the same way as it does for Service Account
3738

3839
Generating access tokens for experimentation with the OAuth Server-to-Server credential is straightforward. You can use the 'Generate access token' button on the credential overview page or copy the cURL command and use the command line to generate an access token for quick use.
3940

41+
![](../../../images/oauth-server-to-server-credential-generate-access-tokens.png)
42+
43+
### Generating access tokens programmatically
44+
45+
See this cURL request to understand how your integration or application can generate access tokens programmatically.
46+
4047
```curl
4148
curl -X POST 'https://ims-na1.adobelogin.com/ims/token/v3' \
4249
-H 'Content-Type: application/x-www-form-urlencoded' \
4350
-d 'client_id={CLIENT_ID}&client_secret={CLIENT_SECRET}&grant_type=client_credentials&scope={SCOPES}'
4451
```
4552

46-
![](../../../images/oauth-server-to-server-credential-generate-access-tokens.png)
53+
Your integration can generate access tokens when needed. However, it is a good practice to cache access tokens for reuse until they expire. Integrations should avoid generating a new access token when a previously generated access token has not expired and can be reused. Adobe can throttle your integration if it generates too many access tokens.
54+
55+
Access tokens usually expire in 24 hours. To check the expiry time of an access token, see the `expires_in` field in the API response returned by the above cURL request. Note: The `expires_in` time is in seconds. See [API reference](./IMS.md#fetching-access-tokens).
4756

4857
### Generating access tokens using standard OAuth2 libraries
4958

@@ -96,42 +105,42 @@ Follow the steps below to rotate client secrets programmatically for the OAuth S
96105
1. Add I/O Management API to your project: This API allows your credential to read, add, and delete its client secrets.
97106

98107
2. Go to the OAuth Server-to-Server credential overview page and grab the URL. For example -
99-
```
100-
https://developer.adobe.com/console/projects/23294/4566206088344958295/credentials/436084/details/oauthservertoserver
101-
```
108+
```
109+
https://developer.adobe.com/console/projects/23294/4566206088344958295/credentials/436084/details/oauthservertoserver
110+
```
102111
103112
3. Grab the value of `org id` and `credential id` from the URL by comparing it to the templated URL below.
104-
```
105-
https://developer.adobe.com/console/projects/{orgId}/{projectId}/credentials/{credentialId}/details/oauthservertoserver
106-
```
113+
```
114+
https://developer.adobe.com/console/projects/{orgId}/{projectId}/credentials/{credentialId}/details/oauthservertoserver
115+
```
107116
108117
4. Construct the secrets request endpoint by substituting the value of `org id` and `credential id` in the URL below.
109-
```
110-
https://api.adobe.io/console/organizations/{orgId}/credentials/{credentialId}/secrets
111-
```
112-
```
113-
https://api.adobe.io/console/organizations/23294/credentials/436084/secrets
114-
```
118+
```
119+
https://api.adobe.io/console/organizations/{orgId}/credentials/{credentialId}/secrets
120+
```
121+
```
122+
https://api.adobe.io/console/organizations/23294/credentials/436084/secrets
123+
```
115124
116125
5. Generate an access token using the existing client secret (see the section on [generating access tokens](#generate-access-tokens)). Make sure to include scopes that the I/O Management API requires:
117126
118-
```AdobeID, openid, read_organizations, additional_info.projectedProductContext, additional_info.roles, adobeio_api, read_client_secret, manage_client_secrets```
127+
```AdobeID, openid, read_organizations, additional_info.projectedProductContext, additional_info.roles, adobeio_api, read_client_secret, manage_client_secrets```
119128
120129
6. Call the API to list all existing client secrets. Note: you can grab your `client_id` from the OAuth Server-to-Server credential overview page.
121130
122-
```curl
123-
curl -X GET 'https://api.adobe.io/console/organizations/{orgId}/credentials/{credentialId}/secrets' \
124-
-H 'Authorization: Bearer {ACCESS TOKEN GENERATED IN STEP 5}'
125-
-H 'x-api-key: {CLIENT ID FROM STEP 6}'
126-
```
131+
```curl
132+
curl -X GET 'https://api.adobe.io/console/organizations/{orgId}/credentials/{credentialId}/secrets' \
133+
-H 'Authorization: Bearer {ACCESS TOKEN GENERATED IN STEP 5}'
134+
-H 'x-api-key: {CLIENT ID FROM STEP 6}'
135+
```
127136
128-
1. Call the API to add another client secret to your credential. The API response contains the `client_secret` that was added and its `uuid`. This `client_secret` will never be returned in plain text by any other API response. However, you can still find it on the Developer Console UI.
137+
7. Call the API to add another client secret to your credential. The API response contains the `client_secret` that was added and its `uuid`. This `client_secret` will never be returned in plain text by any other API response. However, you can still find it on the Developer Console UI.
129138
130-
```curl
131-
curl -X POST 'https://api.adobe.io/console/organizations/{orgId}/credentials/{credentialId}/secrets' \
132-
-H 'Authorization: Bearer {ACCESS TOKEN GENERATED IN STEP 5}'
133-
-H 'x-api-key: {CLIENT ID FROM STEP 6}'
134-
```
139+
```curl
140+
curl -X POST 'https://api.adobe.io/console/organizations/{orgId}/credentials/{credentialId}/secrets' \
141+
-H 'Authorization: Bearer {ACCESS TOKEN GENERATED IN STEP 5}'
142+
-H 'x-api-key: {CLIENT ID FROM STEP 6}'
143+
```
135144
136145
8. Update your application to use the new client secret.
137146
@@ -140,8 +149,8 @@ curl -X POST 'https://api.adobe.io/console/organizations/{orgId}/credentials/{cr
140149
10. Call the API to delete the old client secret from your credential by passing the `uuid` in the URL
141150
142151
143-
```curl
144-
curl -X DELETE 'https://api.adobe.io/console/organizations/{orgId}/credentials/{credentialId}/secrets/{uuid from step 9}' \
145-
-H 'Authorization: Bearer {ACCESS TOKEN GENERATED IN STEP 5}'
146-
-H 'x-api-key: {CLIENT ID FROM STEP 6}'
147-
```
152+
```curl
153+
curl -X DELETE 'https://api.adobe.io/console/organizations/{orgId}/credentials/{credentialId}/secrets/{uuid from step 9}' \
154+
-H 'Authorization: Bearer {ACCESS TOKEN GENERATED IN STEP 5}'
155+
-H 'x-api-key: {CLIENT ID FROM STEP 6}'
156+
```

0 commit comments

Comments
 (0)