sintaxi / dbox Goto Github PK
View Code? Open in Web Editor NEWNodeJS SDK for Dropbox API (THIS LIBRARY IS OBSOLETE!!)
NodeJS SDK for Dropbox API (THIS LIBRARY IS OBSOLETE!!)
Is there a reason the oauth access token is passed via query parameters for get requests? I'm concerned because this seems like a potential security risk with eavesdropping. It looks like the tokens should instead be passed in the HTTP headers.
when using the get function, the metadata parameter to the callback isn't a object but a string.
This is because it comes from the headerfield 'x-dropbox-metadata' and that isn't evaluated by request to be a JSON object. so before you can use it you need to do JSON.parse(metadata).
For consistens this should be fixed.
I am using this strategy from passport LINK
From that strategy i am getting access_token from dropbox, but when i put that access_token inside var client = app.client(access_token)
it throws me an message { error_description: 'No auth function available for given request', error: 'invalid_request' }
and status 400.
I sometimes get errors in my app which appear to be caused by TCP-level disconnects or server errors from the Dropbox API server. In such cases, it looks like request does not provide a response object in the callback, but the error object is also null, so the dbox code looks for response.statusCode
even though response
is undefined.
2012-05-15T12:16:51+00:00 app[web.1]: TypeError: Cannot read property 'statusCode' of undefined
2012-05-15T12:16:51+00:00 app[web.1]: at Request._callback (/app/node_modules/dbox/dbox.js:134:42)
2012-05-15T12:16:51+00:00 app[web.1]: at Request.callback (/app/node_modules/dbox/node_modules/request/main.js:119:22)
2012-05-15T12:16:51+00:00 app[web.1]: at Request.<anonymous> (/app/node_modules/dbox/node_modules/request/main.js:212:58)
2012-05-15T12:16:51+00:00 app[web.1]: at ClientRequest.<anonymous> (/app/node_modules/dbox/node_modules/request/main.js:209:10)
2012-05-15T12:16:51+00:00 app[web.1]: at Request.emit (events.js:67:17)
2012-05-15T12:16:51+00:00 app[web.1]: at CleartextStream.<anonymous> (http.js:1163:11)
2012-05-15T12:16:51+00:00 app[web.1]: at ClientRequest.emit (events.js:67:17)
2012-05-15T12:16:51+00:00 app[web.1]: at CleartextStream.emit (events.js:67:17)
2012-05-15T12:16:51+00:00 app[web.1]: at Socket.emit (events.js:88:20)
2012-05-15T12:16:51+00:00 app[web.1]: at Socket.onerror (tls.js:1144:17)
Hey.
The readdir() method is not working it seems. Everything else in the API is returning nicely, but with readdir() I simply get a 400 status with nothing else returned. If it returned an error I could then try and diagnose the problem. At present I get [] and that's it.
As for it not working, I've tried adding the root (which is 'dropbox' like everything else) but nothing happens.
Thanks! James
I am getting this error when requesting a token
{ '{"error": "Bad oauth_signature for oauth_signature_method \'PLAINTEXT\'"}': undefined }
When I call delta() on an unauthenticated client, I get the following error:
undefined:1
undefined
^
SyntaxError: Unexpected token u
at Object.parse (native)
at /home/dan/node/node_modules/dbox/lib/oauth.js:26:26
at Object.exports.app.client.delta (/home/dan/node/node_modules/dbox/dbox.js:69:24)
This was the result of my code failing to wait on an asynchronous function to complete, leading it to think a client was authenticated when it was in fact not. Still, shouldn't this be caught (or blocked) by dbox so as to be described a little better in the error?
Here is my code
var downloadUrl, fileTitle;
downloadUrl = transfers[i].downloadUrl;
fileTitle = transfers[i].title;
var upload_id = null,
offset = 0,
options = {
'url' : downloadUrl,
'headers': {
'Authorization': 'Bearer ' + req.user.google.access_token
}
};
var requestGet = request.get(options);
requestGet
.on('data', function (chunk) {
console.log('on data');
var params = {};
if (offset > 0) {
params.offset = offset;
}
if (upload_id !== null) {
params.upload_id = upload_id;
}
requestGet.pause();
client.chunk(chunk, params, function (status, reply) {
if (upload_id === null) {
upload_id = reply.upload_id;
}
offset = reply.offset;
console.log(upload_id, (offset / 1024 / 1024).toFixed(2) + ' mb');
requestGet.resume();
});
})
.on('end', function () {
client.commit_chunks(fileTitle, {
upload_id: upload_id,
overwrite: false
}, function (status, reply) {
console.log('File was uploaded', status, reply);
});
})
.on("error", function (err) {
console.log('error', error);
});
After uploading I get a broken file (screen 1, screen 2)
This problem only with Microsoft documents
I followed the readme to create the client with access_token, I can get info from client.account
, but always get 403 error when do client.put
and client.get
.
Please help what's the possible cause? At Dropbox side, I made permission type as full dropbox.
Hi,
I'm a bit confused. Is it possible to go through the authentication process with everyauth and then set this node-dbox clients access token etc to the result?
Would one need to write a setter function of some sort for this?
Thanks for any help!
Elias
By the spec., the thumbnails URL is https://api-content.dropbox.com/1/thumbnails//.
In dbox.js, it is coded like "https://api.dropbox.com/1/thumbnails/"... in line 193.
Currently helper.url uses path.join to build a uri. This doesn't work in windows as path.join uses the path.sep which is "" in windows. Urls then get built like http:\google.com\anotherpath\
http://nodejs.org/api/path.html
http://nodejs.org/api/path.html#path_path_sep
I've got a local fork going with the ability to stream file requests. I'm using it to pipe dropbox files to various places, like an http.Response
.
Would you accept this new method? I tried to get the existing get
method to stream, but I couldn't make it work without code changes. It's a pretty small patch. Let me know!
Hi
sorry if get the terminology incorrect (and if this is my stupidity rather then and issue /bug)
but i am having an issue with dbox when i run the command-line version with no user loged in (System is an unattended RPI )
i have a small bash script that i run on occasion which does the command (the bash script is run from a python script )
the bash script is as below (with tokens removed) , it all works great as long as there is a user logged in via SSH if there is no user loged in then dbox it returns "[]"
is this a bug? or am i making a mistake in my usage? im open to suggestions
It does however need to be stated via the python script as that first starts up the modem/internet and checks its connected etc (its a mobile low power device)
DROPBOX_ACCESS_TOKEN=xxx DROPBOX_USER_ID=xxx dbox push /home/pi
also note python script is run as root on boot and when running the bash script uses the following
import subprocess
proc = subprocess.Popen(["/home/pi/job.sh"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
(out, err) = proc.communicate()
print "dbox output:", out
time.sleep(4)
Maybe this method should be remade a bit. right now it only gives you the info of the URL in an array. I could think of a number of situations where it would make more sense to return the hole metadata object in an array so the user him self could make the filtering.
Maybe add some standard filter options as argument (only files/dir's, special files, regex of filename etc.) so it instead of readdir method it became more of an recursive search function?
What do you all think about that?
Hail -
I've been experimenting with your node-dbox
library and have been enjoying using it so far.
In my application I've created a recursive readdir
method that can crawl all files and directories in a dropbox folder path using node-dbox
. It has a some-what configurable concurrency delay ( as to not spam dropbox api ). It also can create an object hash of file paths with getter methods for file reading, so that you may crawl first, and load files lazily later.
Would you be willing to accept such a feature to node-dbox
? If so, I can try to do a pull request.
First day using dropbox API, so I'm hoping I didn't miss something obvious...
How can I upload a folder and all the contents to dropbox?
On line 28 of Oauth.js signature is being encoded twice.
var getSignature = function(tokenSecret){
return encode(consumerSecret) + "&" + encode(tokenSecret)
}
var signature = encode(getSignature(secret))
Changing it to the following solves the problem of not being able to receive an oauth token.
var signature = getSignature(secret)
Got a JSON parse error thrown when making a call to the files_put
endpoint while the Dropbox service was down:
SyntaxError: Unexpected token <
at Object.parse (native)
at Request.exports.app.client.put [as _callback] (./node_modules/dbox/dbox.js:142:57)
at Request.init.self.callback (./node_modules/dbox/node_modules/request/main.js:119:22)
at Request.<anonymous> (./node_modules/dbox/node_modules/request/main.js:525:16)
at Request.EventEmitter.emit (events.js:88:17)
at IncomingMessage.Request.start.self.req.self.httpModule.request.buffer (./node_modules/dbox/node_modules/request/main.js:484:14)
at IncomingMessage.EventEmitter.emit (events.js:115:20)
at IncomingMessage._emitEnd (http.js:366:10)
at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
at CleartextStream.socketOnData [as ondata] (http.js:1366:20)
Perhaps if the response has status code >= 500 the function should return an error to the callback?
When I install dbox with npm I get the following warning:
package.json: bugs['web'] should probably be bugs['url']
Hello
I have dbox in use on a production server (http://www.silex.me/silex/) and something like 2 times a day, the server seems to be down, because the calls to requesttoken and accesstoken never come back (do not call the callback at all)
I use it like this
dboxapp.accesstoken(request.session.dropbox_request_token, function(status, access_token){
... it stops calling this ...
Have you had this problem before?
Thank you in advance for you answer and the great lib :)
can we use oAuth 2.0 token for this?
Hey there,
I'm new to this library, so apologies if this has been asked to death or is by design -- didn't find anything in a search besides #15 which briefly mentions it.
This library would play a lot nicer with Node async flow management tools and libraries if its callbacks followed the standard (err, result) convention. Have you considered that?
I know it'd be a backwards-incompatible change, so a major version bump would be warranted, but, without knowing history or context, seems like it would be a great change to make.
So to clarify, err would have to be null for all successful responses, and non-null for successful ones. Perhaps the result could get a statusCode property (or e.g. _statusCode) added to it if knowing the status code is helpful even in non-error cases.
What do you think? Thanks for consideration and great work otherwise!
Hello,
Was wondering if it would be possible for metadata to return the file name, currently only looks like path is returned. Granted I can get the file name from the path, but that just seems like an un-needed step, since dropbox's api already should return the name.
I see from #15 that code was changed to mitigate fatal errors in the event of a non-returned request object.
I'm still getting these at line 101 in dbox.js, Was this line unchanged for a reason, or just accidentally missed last time?
thanks
Andy
How do we programtically pass redirect/callback URL where User needs to be redirected back?
Hi there,
Thank you for this great library. I'm using it on my windows dev machine and I couldn't get the readdir function to work. At first I was getting the following error:
var rx = RegExp("^" + scopePath, "i")
SyntaxError: Invalid regular expression: /^/: \ at end of pattern
at new RegExp ()
at RegExp ()
at Object.parseJSON (f:\projects\test\node_modules\dbox\lib\helpers.j
s:23:13)
at Request._callback (f:\projects\test\node_modules\dbox\lib\dbox.js:
231:69)
at Request.self.callback (f:\projects\test\node_modules\dbox\node_mod
ules\request\main.js:119:22)
...
This was caused by some backslashes so in helpers.js I just replaced
var scopePath = path.join("/", scope)
with
var scopePath = path.join("/", scope).replace("\\", "/");
With this my server stopped crashing whenever I was running the readdir function but I still only got a status 400 and no reply from the function. Upon further inspection I realized you guys are using nodejs' path library to build URLs which works great on unix systems but doesn't work in windows because by default it will use the backslash. I tried doing .replace() again but that didn't work so I replaced
fullpath = path.join(obj.hostname)
fullpath = path.join(fullpath, obj.version || "1")
fullpath = path.join(fullpath, obj.action)
fullpath = path.join(fullpath, rootpath)
fullpath = path.join(fullpath, scopepath)
fullpath = path.join(fullpath, filepath)
with
var fullpath = [
obj.hostname,
obj.version || "1",
obj.action,
rootpath,
scopepath,
filepath
].join('/');
And with that the readdir function began working properly on windows as well.
Is there any chance these 2 fixes (or better ones) could make it into the repo so that we (windows devs) don't need to redo them after npm install / version changes / whatever?
Cheers and thanks for the great library!
So I'm writing an app that only uses my specific dropbox account, so I don't need any of the oauth stuff. Can I initiate a 'client' that's just based on my token?
thanks
Hi,
The exception occures when I invoke a function from Client
The screenshot:
http://screencast.com/t/YIRjMVi20jiS
The text:
C:!Hg\timetracker\node_modules\dbox\lib\helpers.js:25
var rx = RegExp("^" + scopePath, "i")
^
SyntaxError: Invalid regular expression: /^/: \ at end of pattern
at new RegExp (unknown source)
at RegExp (unknown source)
at Object.module.exports.parseJSON (C:!Hg\timetracker\node_modules\dbox\lib\helpers.js:25:16)
at Request.exports.app.client.account as _callback
at Request.init.self.callback (C:!Hg\timetracker\node_modules\dbox\node_modules\request\main.js:119:22)
at Request. (C:!Hg\timetracker\node_modules\dbox\node_modules\request\main.js:525:16)
at Request.EventEmitter.emit (events.js:96:17)
at IncomingMessage.Request.start.self.req.self.httpModule.request.buffer (C:!Hg\timetracker\node_modules\dbox\node_modules\request\main.js:484:14
)
at IncomingMessage.EventEmitter.emit (events.js:126:20)
at IncomingMessage._emitEnd (http.js:366:10)
DEBUG: Program node app.js exited with code 1
Metadata returns JSON, but it is not parsed before being returned to the user. Is there a reason it isn't being parsed?
client.account( function(status, reply) { console.log(reply) });
gives me the error:
TypeError: Path must be a string. Received undefined
at assertPath (path.js:8:11)
at Object.posix.join (path.js:479:5)
at Object.parseJSON (/Users/merhawi/Documents/hubs/codehub/meteor/base-3.4.0/node_modules/dbox/lib/helpers.js:22:28)
at Request._callback (/Users/merhawi/Documents/hubs/codehub/meteor/base-3.4.0/node_modules/dbox/lib/dbox.js:61:60)
at Request.self.callback (/Users/merhawi/Documents/hubs/codehub/meteor/base-3.4.0/node_modules/request/main.js:119:22)
at Request.<anonymous> (/Users/merhawi/Documents/hubs/codehub/meteor/base-3.4.0/node_modules/request/main.js:525:16)
at emitOne (events.js:77:13)
at Request.emit (events.js:169:7)
at IncomingMessage.<anonymous> (/Users/merhawi/Documents/hubs/codehub/meteor/base-3.4.0/node_modules/request/main.js:484:14)
at emitNone (events.js:72:20)
when I have supplied the key, secret, token and everything
querystring.escape
doesn't escape !'()*
. Dropbox allows at least a few of them in filenames and requires them to be escaped.
I am not able to include request module in my dbox.js.
I have successfully run the command "npm install request" and downloaded the the request module folder. but it doesn't contain the request.js file.
how to include this request module in my titanium android project.
waiting for reply..!
Hi,
I've got an app that connects to several 3rd-party services, including Dropbox, so I'm using everyauth for the authorization. So for a given authenticated user I already have the appToken, appSecret, accessToken, and accessTokenSecret ... now I want to pass those (the last 2 I guess) into a dbox client to use the API.
So far I've got,
var dbox = require('dbox').app({
app_key: conf.dropbox.appKey,
app_secret: conf.dropbox.appSecret
});
...
var client = dbox.client(req.session.auth.dropbox.accessToken);
client.readdir('/', callback);
but it's giving me a 401. What am I missing?
Thanks!
I don't know if this is a dropbox issue or something else, but when I look at the request object on "put" it has the following values:
r.connection.authorized: false
r.connection.authorizationErrors: Hostname/IP doesn't match certificate's altnames
This is still working because the request object does not have "rejectUnauthorized: true" set.
The correct behavior should be to fail if the certificate can't be verified.
when using the readdir function you get following error:
/var/www/clients/client1/web1/web/nemreg/dropbox/node_modules/dbox/dbox.js:180
self.client.metadata(path, function (status, reply) {
^
TypeError: Cannot call method 'metadata' of undefined
at Object._onTimeout (/var/www/clients/client1/web1/web/nemreg/dropbox/node_modules/dbox/dbox.js:180:27)
at Timer.ontimeout (timers.js:84:39)
Hi, I've build a dbox shell, build on top of your node-dbox
. https://github.com/chilijung/dbox-shell . Please have a look ! :)
I am new in titanium app development. and I am banging my head against wall for last 2 to 3 days but couldn't get a success in calling dropbox api.
I have installed node.js and afterwards run the command in my folder containing the package.json and it successfully loaded few of dependencies.
but in dbox.js two files are included
I couldn't locate these files.
please some one guide me what to do...
I try to run the tests and I get:
prompt: please authorize application at the following url and enter when done https://www.dropbox.com/1/oauth/authorize?oauth_token=undefined:
Same thing when trying to authorize using the example from the doc.
In fetching thumbnail using the dbox.js, encoding problem exists. So I added a line in dbox.js.
line# 192 : ,"encoding": "binary" between "url": "https://api-content.dropbox.com/1/thumbnails/........... and } in thumbnails value.
It switch on the encoding options in "request" nodejs module(dbox/node_modules/request/main.js. - response.setEncoding(options.encoding) ).
Refer below link.
http://stackoverflow.com/questions/3709391/node-js-base64-encode-a-downloaded-image-for-use-in-data-uri
Right now when you clone the repo and installs the dependencies (npm install
in the main dir) and afterwards runs node test/all.js
it results in an error.
This is because of the missing dependency to the jasmine library (i assume).
I think the npm dependencies should be updated so the test libraries is pulled when you run npm install
.
An alternative could be make a section in the readme.md and explain here what to do when you need to run a test.
from node.js v0.10, path.join raises an error if its arguments are not all strings
How to a upload a file (stream not buffer) ?
I have a large file 11GB, the heap size is limited so I can't read the entire content and pass it to the .put method as buffer or string. I there any way to pass a stream or something ?
Is it possible to use already known access token and secret to initialize a new Client?
C:\Program Files\nodejs\node_modules\dbox\lib\helpers.js:23
var rx = RegExp("^" + scopePath, "i")
^
SyntaxError: Invalid regular expression: /^/: \ at end of pattern
at new RegExp (unknown source)
at RegExp (unknown source)
Is there a good reason for appending the args
into the global options
variable? This means that if I pass an argument like { parent_rev : 'foo' }
to a put
request it gets injected into options
variable. It is then always sent on subsequent requests, and this throws an error from the API since calls like get
don't understand parent_rev
.
If this is an accident rather than by design then I will put together a patch that stops this happening and makes each args
local to its own request.
Regards,
James
If you're busy, maybe put a call in the readme for maintainers? The dropbox hosted API is basically a bust and the docs are no longer hosted. Would be nice to have a working nodejs implementation of the Dropbox API
Ok, this one is my fault :-)
Maybe I'll have some time over next week-end to send another pull request your way…
First value returned from function call should be an error which is falsey if no error is triggered. Important to follow this convention for library support, ie Bluebird etc
how to clear cookies in titanium android and logout from dropbox. I am only able to create a folder in my dropbox. but afterwards the application doesn't even work. it just shows the titanium startup page and never shows the drop box directories...
I cannot not figure out the problem as I am new to titanium as well as drop box api.
any help would be greatly appreciated..!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.