Socket
Socket
Sign inDemoInstall

node-dropbox

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-dropbox - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

17

lib/node_dropbox.js

@@ -21,9 +21,16 @@ var request = require('request');

exports.Authenticate = function(ckey, csecret, redirect_uri) {
return {
redirect_uri: "" + authUrl + "client_id=" + ckey + "&response_type=code&redirect_uri=" + redirect_uri + ""
exports.Authenticate = function(ckey, csecret, redirect_uri, cb) {
var err = "";
var redirect_url = "";
if(ckey === "" || csecret === "" || redirect_uri === "") {
err = "Missing client key and/or client secret key.";
}else{
redirect_url = authUrl + "client_id=" + ckey + "&response_type=code&redirect_uri=" + redirect_uri;
}
cb(err, redirect_url);
}
exports.AccessToken = function(ckey, csecret, auth_code, redirect_url) {
exports.AccessToken = function(ckey, csecret, auth_code, redirect_url, cb) {
var url = apiRoot + '/oauth2/token';

@@ -39,3 +46,3 @@ var body = {

request.post(url, {form: body}, function(err, res, body) {
return body;
cb(err, body);
});

@@ -42,0 +49,0 @@ }

{
"name": "node-dropbox",
"description": "A simple Dropbox API client for node.js",
"version": "0.1.1",
"version": "0.1.2",
"author": "Joshua Kidd <kidd.josh.343@gmail.com>",

@@ -6,0 +6,0 @@ "keywords": [

@@ -18,13 +18,12 @@ # Node Dropbox

var node_dropbox = require('node_dropbox');
node_dropbox.Authenticate('key', 'secret', 'redirect_url');
node_dropbox.Authenticate('key', 'secret', 'redirect_url', function(err, url){
// redirect user to the url.
// looks like this: "https://www.dropbox.com/1/oauth2/authorize?client_id=<key_here>&response_type=code&redirect_uri=<redirect_url_here>"
});
This will return something similar to below. You will need to redirect your user to this url.
{
redirect_uri: "https://www.dropbox.com/1/oauth2/authorize?client_id=<key_here>&response_type=code&redirect_uri=<redirect_url_here>"
}
On the page where you redirected to, you will need to use the AccessToken method to get the users access token for api use. The redirect_url this time is only for validation, it will not need to redirect again.
access_token = node_dropbox.AccessToken('key', 'secret', 'access_code', 'redirect_url');
node_dropbox.AccessToken('key', 'secret', 'access_code', 'redirect_url', function(err, body) {
access_token = body.access_token;
});

@@ -31,0 +30,0 @@ #### Make API Calls

{
"app_key": "0jr750as3jczzcg",
"app_secret": "jqpeifmo57q5fh4",
"access_token": "your-key-here",
"access_token": "hxcbULMjmkYAAAAAAAAAPf1kBka-LtZTpMjYI-tA0L-f5PxEnnTxtZ7vp8-k-N57",
"redirect_url": "http://localhost:3000/dropbox_callback"
}

@@ -5,3 +5,3 @@ var fs = require("fs")

describe("new", function() {
describe("Node Dropbox", function() {
var config = JSON.parse(fs.readFileSync(__dirname + '/config/config.json'))

@@ -15,2 +15,22 @@ var api, ref;

describe("#Authenticate", function() {
it("should create valid auth url", function(done) {
link = "https://www.dropbox.com/1/oauth2/authorize?client_id=" + config.app_key + "&response_type=code&redirect_uri=" + config.redirect_url;
node_dropbox.Authenticate(config.app_key, config.app_secret, config.redirect_url, function(err, url) {
url.should.eql(link)
err.should.eql("")
done()
})
})
it("should validate params", function(done) {
node_dropbox.Authenticate(config.app_key, "", config.redirect_url, function(err, url) {
err.should.eql("Missing client key and/or client secret key.");
done();
})
})
})
it("should get account object", function(done) {

@@ -17,0 +37,0 @@ api.account(function(err, res, body) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc