Retrieve an Adobe access token through the 2-legged Oauth server-to-server flow
Instead of every developer who wants to use the Oauth server-to-server flow to retrieve an auth token from Adobe having to write their own implementation of this flow this package is intended to replace this need with one method call.
Instructions for how to download/install the code onto your machine.
Example:
npm install --save @adobe/auth-token
The config object is where you pass in all the required and optional parameters to the auth
call.
parameter | integration name | required | type | Accepted Option |
---|---|---|---|---|
clientId | Client ID | true | String | |
clientSecret | Client Secret | true | String | |
scope | scope | true | Comma separated String or Array | |
env | false | String | prod OR stage |
Usage instructions for your code.
This library is ESM first:
import { auth } from '@adobe/auth-token';
Usage in CommonJS modules:
const auth = (...args) => import('@adobe/auth-token').then(({ auth: adobeAuth }) => adobeAuth(...args));
Promise-based example:
import { auth } from '@adobe/auth-token';
const config = {
clientId: "your-client-id",
clientSecret: "your-client-secret",
scope: "your-scopes"
}
auth(config)
.then((tokenResponse) => console.log(tokenResponse))
.catch((error) => console.log(error));
Async/Await based example:
import { auth } from '@adobe/auth-token';
const config = {
clientId: "your-client-id",
clientSecret: "your-client-secret",
scope: "your-scopes"
}
const { access_token, token_type, expires_in } = await auth(config);
In order to determine which scope you need to register for you can look them up by product in this handy table.
For instance if you need to be authenticated to call API's for both GDPR and User Management you would look them up and find that they are:
- GDPR: https://ims-na1.adobelogin.com/s/ent_gdpr_sdk
- User Management: https://ims-na1.adobelogin.com/s/ent_user_sdk
Then you would create an array of metaScopes as part of the config object. For instance:
const config = {
clientId: "asasdfasf",
clientSecret: "aslfjasljf-=asdfalasjdf==asdfa",
scope: ["ent_dataservices_sdk", "reactor_publisher"],
env: "stage"
};
Contributions are welcomed! Read the Contributing Guide for more information.
This project is licensed under the Apache V2 License. See LICENSE for more information.