@sp-api-sdk/auth
TypeScript icon, indicating that this package has built-in type declarations

2.0.7 • Public • Published

@sp-api-sdk/auth

Amazon Selling Partner API authentication package

Installing

  • npm install @sp-api-sdk/auth

Default values from the environment

These constructor options can be passed using environment variables:

Property Name Environement variable
clientId LWA_CLIENT_ID
clientSecret LWA_CLIENT_SECRET
refreshToken LWA_REFRESH_TOKEN

Grantless APIs support

Some APIs require grantless authentication, which is done by passing scopes, instead of a refresh token. The available scopes are exposed in the AuthorizationScope enum from this library.

import { SellingPartnerApiAuth, AuthorizationScope } from "@sp-api-sdk/auth";
import { AuthorizationApiClient } from "@sp-api-sdk/authorization-api-v1";

const auth = new SellingPartnerApiAuth({
  clientId: "",
  clientSecret: "",
  scopes: Object.values(AuthorizationScope), // Or choose the only ones you need
});

const accessToken = await auth.getAccessToken();

Credentials caching

getAccessToken() caches the access token for its whole duration, it will only request a new token if the current one has expired.

Package Sidebar

Install

npm i @sp-api-sdk/auth

Weekly Downloads

587

Version

2.0.7

License

MIT

Unpacked Size

15.5 kB

Total Files

24

Last publish

Collaborators

  • tusbar