Permalink
Browse files

demo updates

  • Loading branch information...
1 parent 8ad1eef commit 00fbec64a94be131d80f75f388e617964d864710 @simonmcmanus simonmcmanus committed Nov 28, 2012
Showing with 27 additions and 22 deletions.
  1. +2 −10 README.md
  2. +5 −5 examples/search.js
  3. +4 −4 examples/simple.js
  4. +1 −1 package.json
  5. +1 −2 redis.js
  6. +14 −0 server.js
View
12 README.md
@@ -24,6 +24,8 @@ var twitterAuth = require('twitter-oauth')({
});
```
+See examples for more details.
+
If a redis port and host are provided then each request will be cached for 60 seconds.
@@ -53,16 +55,6 @@ Then you can call the service like so:
See the search example to see all the possible searches.
-##TODO
-
-1. Add middleware
-2. Expose redis functionality securely
-
-
-
-
-
-
Twitter 1.1
View
10 examples/search.js
@@ -5,20 +5,20 @@ var http = require('http');
var path = require('path');
var config = {
- consumerKey: "ENTER KEY HERE", /* per appications - manage apps here: https://dev.twitter.com/apps */
- consumerSecret: "ENTER SECRET HERE", /* per appications - manage apps here: https://dev.twitter.com/apps */
- domain: "domain",
+ consumerKey: "sJaEIiV4X014iIC6uvzKDA", /* per appications - manage apps here: https://dev.twitter.com/apps */
+ consumerSecret: "40wRAIu9a9bgAKWWltTP7NutSZxEMsPZJ5UhTZitmgw", /* per appications - manage apps here: https://dev.twitter.com/apps */
+ domain: "http://YOURDOMAIN.com",
login: "/twitter/sessions/connect",
logout: "/twitter/sessions/logout",
loginCallback: "/twitter/sessions/callback", /* internal */
- completeCallback: "/search/gosquared" /* When oauth has finished - where should we take the user too */
+ completeCallback: "http://YOURDOMAIN.com/search/gosquared" /* When oauth has finished - where should we take the user too */
};
var express = require('express');
twitterAuth = require('../server.js')(config);
-var app = express.createServer();
+var app = express();
app.configure(function(){
app.set('port', 83);
View
8 examples/simple.js
@@ -6,18 +6,18 @@ var express = require('express');
var config = {
- consumerKey: "CONSUMER KEYS", /* per appications - manage apps here: https://dev.twitter.com/apps */
- consumerSecret: "CONSUMER SECRET", /* per appications - manage apps here: https://dev.twitter.com/apps */
+ consumerKey: "YOUR CONSUMER KEY HERE", /* per appications - manage apps here: https://dev.twitter.com/apps */
+ consumerSecret: "YOUR CONSUMER SECRET HERE", /* per appications - manage apps here: https://dev.twitter.com/apps */
domain: "http://DOMAIN.com",
login: "/twitter/sessions/connect",
logout: "/twitter/sessions/logout",
loginCallback: "/twitter/sessions/callback", /* internal */
completeCallback: "/search/gosquared" /* When oauth has finished - where should we take the user too */
};
-twitterAuth = require('../app.js')(config);
+twitterAuth = require('../server.js')(config);
-var app = express.createServer();
+var app = express();
app.configure(function(){
app.set('port', 83);
View
2 package.json
@@ -2,7 +2,7 @@
"author": "Simon McManus <simon@gosquared.com>",
"name": "twitter-oauth",
"main": "server.js",
- "version": "0.0.2",
+ "version": "0.0.1",
"repository": {
"type": "git",
"url": "git@github.com:gosquared/twitter-oauth.git"
View
3 redis.js
@@ -1,8 +1,7 @@
/*
-Small redis wrapper, not really needed anymore.
- */
+Small redis wrapper, not really needed anymore but might come in handy if anyone wants to override the default data store (redis) */
module.exports = function(host, port) {
var redis = require('redis');
View
14 server.js
@@ -220,15 +220,27 @@ self.fetch = function(url, oauthToken, oauthTokenSecret, callback) {
req.session.oauthRequestToken = oauthToken; // we will need these values in the oauthCallback so store them on the session.
req.session.oauthRequestTokenSecret = oauthTokenSecret;
+ var connectCallback = function(req, res, next) { // keep track of the site id in the sesion for the callback.
+ console.log('concb');
+ req.session.siteId = req.params.siteId;
+ req.session.apiKey = req.params.apiKey;
+ req.session.siteToken = req.params.siteToken;
+ }
+
if(options.connectCallback) {
options.connectCallback(req, res, next);
+ }else {
+
+ connectCallback(req, res, next);
}
+ console.log('DO REDIRECT');
res.redirect("https://twitter.com/oauth/authorize?oauth_token="+req.session.oauthRequestToken);
}
});
};
self.oauthCallback = function(req, res, next) {
+ console.log('wotcha');
self.consumer.getOAuthAccessToken(req.session.oauthRequestToken, req.session.oauthRequestTokenSecret, req.query.oauth_verifier, function(error, oauthAccessToken, oauthAccessTokenSecret, results) {
if (error) {
res.send("Access Denied." , 500);
@@ -237,8 +249,10 @@ self.fetch = function(url, oauthToken, oauthTokenSecret, callback) {
req.session.oauthAccessToken = oauthAccessToken; // ensure we are clearing the session variables.
req.session.oauthAccessTokenSecret = oauthAccessTokenSecret;
if(options.oauthCallbackCallback) {
+ console.log(1);
options.oauthCallbackCallback(req, res, next, results.screen_name, oauthAccessToken, oauthAccessTokenSecret);
}else {
+ console.log(2);
res.redirect(options.completeCallback);
}
}

0 comments on commit 00fbec6

Please sign in to comment.