From db98be5d24228b933cc4daa66842c7daf9c8e22d Mon Sep 17 00:00:00 2001 From: "DOM1\\fxu" Date: Wed, 17 Jul 2024 19:20:41 -0700 Subject: [PATCH] OAuth2 --- README.md | 6 +++++- lib/DataContext.js | 7 ++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4404dcc..6d8ffa1 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,11 @@ Do cool stuff: ```javascript var api = require('infusionsoft-api'); -var infusionsoft = new api.DataContext('myapp', 'MY_API_KEY'); +var infusionsoft = new api.DataContext( + { + url: 'https://api.infusionsoft.com/crm/xmlrpc', + headers: {Authorization: `Bearer ${access_token}`} + }); infusionsoft.Contacts .where(Contact.FirstName, 'Brandon') diff --git a/lib/DataContext.js b/lib/DataContext.js index 66f0661..a3ceb13 100644 --- a/lib/DataContext.js +++ b/lib/DataContext.js @@ -16,12 +16,9 @@ module.exports = DataContext = typedef // of the services. .class('DataContext') .define({ - __constructor__: function(appName, apiKey) + __constructor__: function(options) { - this.appName = appName; - this.apiKey = apiKey; - this.client = xmlrpc.createSecureClient( - 'https://' + this.appName + '.infusionsoft.com/api/xmlrpc'); + this.client = xmlrpc.createSecureClient(options); this._setupServices(); this._setupTables();