1.0.0-beta.1 • Published 4 months ago

@adobe/auth-token v1.0.0-beta.1

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
4 months ago

Version Downloads/week codecov License Language grade: JavaScript

auth-token

Retrieve an Adobe access token through the 2-legged Oauth server-to-server flow

Goals

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.

Installation

Instructions for how to download/install the code onto your machine.

Example:

npm install --save @adobe/auth-token

Common Usage

Config object

The config object is where you pass in all the required and optional parameters to the auth call.

parameterintegration namerequiredtypeAccepted Option
clientIdClient IDtrueString
clientSecretClient SecrettrueString
scopescopetrueComma separated String or Array
envfalseStringprod OR stage

Usage instructions for your code.

Importing @adobe/auth-token

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:

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"
};

Contributing

Contributions are welcomed! Read the Contributing Guide for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.

1.0.0-beta.12

4 months ago

1.0.0-beta.13

4 months ago

1.0.0-beta.11

4 months ago

1.0.0-beta.10

4 months ago

1.0.0-beta.6

4 months ago

1.0.0-beta.7

4 months ago

1.0.0-beta.8

4 months ago

1.0.0-beta.9

4 months ago

1.0.0-beta.5

5 months ago

1.0.0-beta.3

5 months ago

1.0.0-beta.2

5 months ago

1.0.0-beta.1

5 months ago