New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dropbox-authenticator

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dropbox-authenticator

Easily obtain OAuth credentials for the Dropbox API.

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Dropbox Authenticator

Simple authentication helper for Dropbox.

Installation

$ npm install dropbox-authenticator

Usage

The authenticator is a tiny object that exposes two single functions.

Initiate

The initiate function asks Dropbox for a request token and generates a URL that you should send your user to. You are then responsible for providing a calback URL that Dropbox can send the user to.

NOTE: The Authenticator attaches an ID to the callback URL which makes it possible to have several simultaneous authentication attempts by several users. It does however make it impossible to use your own querystring with the callback url.

Once the user comes back to you, you complete the authorization by calling complete.

Complete

The complete function takes the request and response streams from an HTTP server request listener. As well as a callback function. Once authorization is complete this function is called with the OAuth credentials. It's up to you to store these.

Example

Quick 'n dirty example showing how to use this thing:

var Authenticator = require('dropbox-authenticator');
var http = require('http');
var auth = Authenticator(YOUR_APP_ID, YOUR_APP_SECRET);

// Handle authorizations
http.createServer(function (req, res) {
  if (req.url === '/') {
    auth.initiate('http://mysite.com/authorized', function (err, url) {
      res.write('<a href="' + url + '">Authorize!</a>');
      res.end();
    });
  }
  else {
    auth.complete(req, res, function (err, credentials) {
      // Save credentials or something here
      console.log(credentials);
    });
  }
});

Note that this fails if many users access the server simultaneously. This is because Authenticator needs to store some tokens internally between each step. I'm thinking about a fix for this. In the mean time I recommend doing some kind of session thing and tying one instance of Authenticator to each session.

License

ISC

Keywords

FAQs

Package last updated on 26 Feb 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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