Permalink
Browse files

Merge pull request #2 from grorg/apitoken

Allow use of Pinboard API Token in place of user/pass if provided
  • Loading branch information...
2 parents b7b2336 + a87be0e commit 896a9b327f0842d59815be3bb7633c4b44a0e31b @frozzare committed Jul 30, 2013
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/pinboard.js
View
@@ -6,7 +6,8 @@ var request = require('request'),
*/
init: function (options) {
- this.url = "https://" + options.username + ":" + options.password + "@api.pinboard.in/v1";
+ this.token = options.token || '';
+ this.url = "https://" + (!this.token ? (options.username + ":" + options.password + "@") : "") + "api.pinboard.in/v1";
this.format = options.format || 'json';
},
@@ -280,7 +281,7 @@ var request = require('request'),
*/
formatArguments: function (obj) {
- var str = "?";
+ var str = pinboard.token ? ("?auth_token=" + pinboard.token + "&") : "?";
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
obj[key] = typeof obj[key] === 'string' ? obj[key].replace(/\s+/g, '%20') : obj[key];

0 comments on commit 896a9b3

Please sign in to comment.