UNPKG

@skriptfabrik/n8n-nodes-otto-market

Version:
78 lines 2.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OttoMarketApi = void 0; class OttoMarketApi { constructor() { this.name = 'ottoMarketApi'; this.displayName = 'OTTO Market API'; this.icon = 'file:../icons/Otto.svg'; this.documentationUrl = "https://api.otto.market/docs#section/OTTO-Market-API-Developer's-Guide/Authorization-(OAuth2)"; this.properties = [ { displayName: 'Username', name: 'username', type: 'string', placeholder: 'username', required: true, default: undefined, }, { displayName: 'Password', name: 'password', type: 'string', typeOptions: { password: true, }, required: true, default: undefined, }, { displayName: 'Access Token', name: 'accessToken', type: 'hidden', typeOptions: { expirable: true, password: true, }, default: undefined, }, ]; this.authenticate = { type: 'generic', properties: { headers: { Authorization: '=Bearer {{$credentials.accessToken}}', }, }, }; this.test = { request: { baseURL: 'https://api.otto.market', url: '/v3/products', qs: { limit: 1, }, }, }; } async preAuthentication(credentials) { const response = (await this.helpers.httpRequest({ method: 'POST', url: 'https://api.otto.market/v1/token', headers: { 'content-type': 'application/x-www-form-urlencoded', }, body: new URLSearchParams({ username: credentials['username'], password: credentials['password'], grant_type: 'password', client_id: 'token-otto-api', }), })); return { accessToken: response.access_token, }; } } exports.OttoMarketApi = OttoMarketApi; //# sourceMappingURL=OttoMarketApi.credentials.js.map