Drop in Tumblr API with OAuth for Express.
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
test
.gitignore
LICENSE
README.md
index.js
package.json

README.md

express-tumblr-oauth

Drop in Tumblr API with OAuth for Express.

How

npm install express-tumblr-oauth

Pass your express app through this module and you'll have Tumblr API capabilities.

// ======
// app.js
// ======
var express = require("express")
  , app = express()
  , tumblrAPI = require("express-tumblr-oauth")

var config =
  { oauth:
      { consumer_secret: "YOURSECRETKEY"
      , consumer_key: "YOURCONSUMERKEY"
      , callback: "http://localhost:3000"
      }
  }

tumblrAPI(app, config)

app.listen(3000)

NOTE:

config.oauth.callback should be the base url of your website it will be converted into an appropriate callback url for oauth internally by express-tumblr-oauth

Interface

express-tumblr-oauth adds the following routes to your application

/api/oauth/tumblr/url

$.getJSON("/api/oauth/tumblr/url", function (url) {
  console.log(url) // http://www.tumblr.com/authorize?oauth_token=[oauthtoken]
})

/api/oauth/tumblr/callback

express-tumblr-oauth uses this callback internally to finilize the oauth proccess.

/api/tumblr/*

works as an authorized proxy to the official tumblr API

$.getJSON("/api/tumblr/dashboard", function (data) {
  console.log(data.meta.status) // 200
})

Config options

These are all the options you can pass express-tumblr-oauth and their defaults

var ops = {}

// REQUIRED
ops.oauth =
  { consumer_key: "key"
  , consumer_secret: "secret"
  , callback: "mywebsite.com"
  }

//OPTIONAL

ops.sessionName = "tumblr_oauth"
// used as the variable inside the req.session
// express object.

ops.successRedirect =  "/"
// the path to redirect to when oauth is successfully complete

ops.failureRedirect =  "/"
// the path to redirect to when oauth fails