drip-nodejs
Advanced tools
Comparing version 0.0.7 to 0.1.0
@@ -22,6 +22,11 @@ var Accounts = require('./accounts') | ||
this.token = options.token; | ||
var token = this.token = options.token; | ||
var tokenType = options.tokenType || "Basic"; | ||
if(tokenType === "Basic") { | ||
// Encode the token before setting headers | ||
token = new Buffer(this.token).toString('base64'); | ||
} | ||
this.headers = { | ||
"content-type": "application/vnd.api+json", | ||
"authorization": "Basic " + new Buffer(this.token).toString('base64'), | ||
"authorization": tokenType + " " + token, | ||
"User-Agent": "Drip NodeJS Wrapper" | ||
@@ -28,0 +33,0 @@ } |
{ | ||
"name": "drip-nodejs", | ||
"version": "0.0.7", | ||
"version": "0.1.0", | ||
"description": "A complete NodeJS wrapper for connecting to the Drip v2 REST API", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -17,2 +17,6 @@ [![Build Status](https://travis-ci.org/samudary/drip-nodejs.svg?branch=master)](https://travis-ci.org/samudary/drip-nodejs) | ||
For public integrations with an OAuth2 application registered with Drip, you'll need to specify the type of token you're passing (e.g. "Bearer"): | ||
`var client = require('drip-nodejs')({ token: YOUR_ACCESS_TOKEN, tokenType: TOKEN_TYPE });` | ||
For most API methods, you'll need your Drip Account ID found [here](https://www.getdrip.com/settings/general). Most client methods accept an account ID argument which allows interaction with any account maintained in your Drip account. | ||
@@ -19,0 +23,0 @@ |
@@ -17,3 +17,3 @@ 'use strict'; | ||
it('should add basic auth authorization header', function () { | ||
it('should add basic auth authorization header when no tokenType is specified', function () { | ||
var client = new Client({ token: token }); | ||
@@ -23,2 +23,7 @@ expect(client.headers.authorization).toEqual("Basic " + new Buffer(token).toString('base64')); | ||
it('should add bearer auth authorization header when tokenType is "Bearer"', function () { | ||
var client = new Client({ token: token, tokenType: "Bearer" }); | ||
expect(client.headers.authorization).toEqual("Bearer " + token); | ||
}); | ||
it('should add user-agent header', function () { | ||
@@ -25,0 +30,0 @@ var client = new Client({ token: token }); |
68673
1528
188