n8n/packages/nodes-base/credentials/SegmentApi.credentials.ts

29 lines
712 B
TypeScript
Raw Normal View History

import {
ICredentialDataDecryptedObject,
ICredentialType,
IHttpRequestOptions,
INodeProperties,
} from 'n8n-workflow';
2020-01-23 09:27:28 -08:00
export class SegmentApi implements ICredentialType {
name = 'segmentApi';
displayName = 'Segment API';
documentationUrl = 'segment';
properties: INodeProperties[] = [
2020-01-23 09:27:28 -08:00
{
displayName: 'Write Key',
name: 'writekey',
type: 'string',
2020-01-23 09:27:28 -08:00
default: '',
},
];
async authenticate(
credentials: ICredentialDataDecryptedObject,
requestOptions: IHttpRequestOptions,
): Promise<IHttpRequestOptions> {
const base64Key = Buffer.from(`${credentials.writekey}:`).toString('base64');
requestOptions.headers!['Authorization'] = `Basic ${base64Key}`;
return requestOptions;
}
2020-01-23 09:27:28 -08:00
}