JSPM

  • Created
  • Published
  • Downloads 1830
  • Score
    100M100P100Q108752F
  • License MIT

Auth library for helping authentication with Selling Partner API

Package Exports

  • @sp-api-sdk/auth

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@sp-api-sdk/auth) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@sp-api-sdk/auth

Package for simplifying authentication with Selling Partner API

Installing

  • yarn add @sp-api-sdk/auth
  • npm install @sp-api-sdk/auth

Usage

With Security Token Service :

import {SellingPartnerApiAuth} from '@sp-api-sdk/auth'

const auth = new SellingPartnerApiAuth({
  clientId: '',
  clientSecret: '',
  refreshToken: 'Atzr|...',
  accessKeyId: '',
  secretAccessKey,
  role: {
    arn: roleArn,
    sessionName: 'SellingPartnerAPI'
  },
})

const accessToken = await auth.accessToken.get()
const { AccessKeyId, SecretAccessKey, SessionToken } = await auth.getCredentials()

With an AWS user :

import {SellingPartnerApiAuth} from '@sp-api-sdk/auth'

const auth = new SellingPartnerApiAuth({
  clientId: '',
  clientSecret: '',
  refreshToken: 'Atzr|...',
  accessKeyId: '',
  secretAccessKey,
  user: {
    AccessKeyId: '',
    SecretAccessKey: ''
  }
})

const accessToken = await auth.accessToken.get()
const { AccessKeyId, SecretAccessKey } = await auth.getCredentials()

Everytime you get the access token, the class will check before if the token has already been fetch or if it's still valid, if not, it will fetch it.

Same for the given credentials from Security Token Service