UNPKG

@hyperse/paypal-node-sdk

Version:

NodeJS SDK for PayPal Checkout APIs

33 lines (32 loc) 1.11 kB
import { HttpRequestBase } from './HttpRequestBase.js'; import {} from './PayPalEnvironment.js'; /** * An OAuth2 client credentials grant access token request * Documentation * @see {@link https://github.com/hyperse-io/paypal-node-sdk/tree/main/src/core/AccessTokenRequest.ts} */ export class AccessTokenRequest extends HttpRequestBase { /** * @param environment The environment for this request (sandbox or live) * @param refreshToken - An optional refresh token to use refreshing instead of granting */ constructor(environment, refreshToken) { super(); this.body = { grant_type: 'client_credentials', refresh_token: '', }; if (refreshToken) { this.body = { grant_type: 'refresh_token', refresh_token: refreshToken, }; } this.path = '/v1/oauth2/token'; this.verb = 'POST'; this.headers = { 'Content-Type': 'application/x-www-form-urlencoded', Authorization: environment.authorizationString(), }; } }