express-tumblr-oauth

"Drop in Tumblr API with OAuth for Express"

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)

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

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

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

works as an authorized proxy to the official tumblr API

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

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