Skip to content

Commit

Permalink
Apply auth header from token
Browse files Browse the repository at this point in the history
  • Loading branch information
zarathustra323 committed Oct 12, 2018
1 parent 325f292 commit b695453
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const soap = require('soap');
const MarketingCloudAuth = require('marketing-cloud-auth');
const applyAuthHeader = require('./utils/apply-auth-header');

class MarkingCloudSOAP {
/**
Expand Down Expand Up @@ -35,7 +36,11 @@ class MarkingCloudSOAP {
this.clientPromise = soap.createClientAsync(this.wsdl, this.soapOptions);
}
try {
const client = await this.clientPromise;
const [token, client] = await Promise.all([
this.auth.retrieve(),
this.clientPromise,
]);
applyAuthHeader(client, `<fueloauth>${token.value}</fueloauth>`);
return client;
} catch (e) {
this.clientPromise = undefined;
Expand Down

0 comments on commit b695453

Please sign in to comment.