Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow key pair to be specified in optional args object passed to meth…

…ods invoking Dropbox API.
  • Loading branch information...
commit c209d0d37215c59336673df824a6d558746c0fa9 1 parent b2bc8d8
@evnm evnm authored
Showing with 18 additions and 9 deletions.
  1. +18 −9 lib/dropbox-node/index.js
View
27 lib/dropbox-node/index.js
@@ -45,7 +45,8 @@ DropboxClient.prototype.getAccountInfo = function(optargs, callback) {
this.oauth.get(API_URI + '/account/info/' +
(optargs.status_in_response ? '?status_in_response=' +
optargs.status_in_response : ''),
- this.access_token, this.access_token_secret,
+ optargs.token || this.access_token,
+ optargs.secret || this.access_token_secret,
function(err, data, res) {
if (err) callback(err);
else callback(null, JSON.parse(data));
@@ -57,7 +58,8 @@ DropboxClient.prototype.getAccountInfo = function(optargs, callback) {
DropboxClient.prototype.getFile = function(path, callback) {
path = escapePath(path);
this.oauth.get(CONTENT_API_URI + '/files/dropbox/' + path,
- this.access_token, this.access_token_secret,
+ optargs.token || this.access_token,
+ optargs.secret || this.access_token_secret,
function(err, data, res) {
callback(err, data);
});
@@ -79,7 +81,8 @@ DropboxClient.prototype.putFile = function(file, path, callback) {
path = escapePath(path);
this.oauth.post(CONTENT_API_URI + '/files/dropbox/' + path +
'?file=' + file,
- this.access_token, this.access_token_secret,
+ optargs.token || this.access_token,
+ optargs.secret || this.access_token_secret,
body, content_type,
function(err, data, res) {
if (err) callback(err);
@@ -94,7 +97,8 @@ DropboxClient.prototype.getMetadata = function(path, optargs, callback) {
path = escapePath(path);
this.oauth.get(API_URI + '/metadata/dropbox/' + path +
(optargs ? '?' + querystring.stringify(optargs) : ''),
- this.access_token, this.access_token_secret,
+ optargs.token || this.access_token,
+ optargs.secret || this.access_token_secret,
function(err, data, res) {
if (err) callback(err);
else callback(null, JSON.parse(data));
@@ -109,7 +113,8 @@ DropboxClient.prototype.getThumbnail = function(path, optargs, callback) {
path = escapePath(path);
this.oauth.get(CONTENT_API_URI + '/thumbnails/dropbox/' + path
+ (optargs ? '?' + querystring.stringify(optargs) : ''),
- this.access_token, this.access_token_secret,
+ optargs.token || this.access_token,
+ optargs.secret || this.access_token_secret,
function(err, data, res) {
callback(err, data);
});
@@ -125,7 +130,8 @@ DropboxClient.prototype.copy = function(from_path, to_path, callback) {
querystring.stringify({root: 'dropbox',
from_path: from_path,
to_path: to_path}),
- this.access_token, this.access_token_secret,
+ optargs.token || this.access_token,
+ optargs.secret || this.access_token_secret,
function(err, data, res) {
if (err) callback(err);
else callback(null, JSON.parse(data));
@@ -140,7 +146,8 @@ DropboxClient.prototype.createFolder = function(path, callback) {
this.oauth.get(API_URI + '/fileops/create_folder?' +
querystring.stringify({root: 'dropbox',
path: path}),
- this.access_token, this.access_token_secret,
+ optargs.token || this.access_token,
+ optargs.secret || this.access_token_secret,
function(err, data, res) {
if (err) callback(err);
else callback(null, JSON.parse(data));
@@ -155,7 +162,8 @@ DropboxClient.prototype.deleteItem = function(path, callback) {
this.oauth.get(API_URI + '/fileops/delete?' +
querystring.stringify({root: 'dropbox',
path: path}),
- this.access_token, this.access_token_secret,
+ optargs.token || this.access_token,
+ optargs.secret || this.access_token_secret,
function(err, data, res) {
if (err) callback(err);
else callback(null, JSON.parse(data));
@@ -172,7 +180,8 @@ DropboxClient.prototype.move = function(from_path, to_path, callback) {
querystring.stringify({root: 'dropbox',
from_path: from_path,
to_path: to_path}),
- this.access_token, this.access_token_secret,
+ optargs.token || this.access_token,
+ optargs.secret || this.access_token_secret,
function(err, data, res) {
if (err) callback(err);
else callback(null, JSON.parse(data));
Please sign in to comment.
Something went wrong with that request. Please try again.