Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Jacob committed May 6, 2012
0 parents commit 3816cd7
Show file tree
Hide file tree
Showing 23 changed files with 2,627 additions and 0 deletions.
65 changes: 65 additions & 0 deletions README.md
@@ -0,0 +1,65 @@
# OhAuth!
## Lazy OAuth for Express

### 1. How Lazy?
How about this -- here's your server js:

var Express = require('express')
, app = Express.createServer(Express.favicon(),Express.static(__dirname))
, OhAuth = require('./ohauth')
, strategies = require('./ohauth-strategies');


var cK = 'consumerKey', cS = 'consumerSecret'
, ohAuth = new OhAuth(strategies.twitter(cK,cS,'http://127.0.0.1:1337',app);

app.configure(function(){
app.use(app.router);
});

app.listen(1337);
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});

// when you're done, you'll get an access key and an access secret printing out here
app.get('/oauth/success',function(req,res){
res.send(req.session.credentials);
});

Now, after a little `node app.js`, just point your browser over to `localhost:1337/oauth/login`


### 2. Wait, so it does everything for me?
Pretty much. It has some defaults that can be changed by passing new values (either in the strategy, or the dict if you're using your own).

* loginURL: `/oauth/login`
* callbackURL: `/oauth/callback`
* sucessURL: `/oauth/succecss`
* errorURL: `/oauth/error`

It sets up all of them except *success*, because I figured you'd probably want to implement it yourself. `/oauth/login` goes straight to twitter.

### 3. I want to make API calls..what do?
There are methods for GET and POST that just wrap the node-oauth library (what this whole things is wrapping). Check it out:

#### Get request:

ohAuth.get({ accessToken: '', accessSecret: '' },url,params,function(status,data,response){
console.log(response); // there's the return of the call
});

#### Post request:

ohAuth.post({ accessToken: '', accessSecret: '' },url,params,function(status,data,response){
console.log(response); // there's the return of the call
},contentType); // contentType is an optional parameter..oh and params is optional too

### 3. Giant Disclaimer
This is not fully tested, and probably has a lot of issue in the smaller details. It's really just a wrapper around oauth.js, and etc. and use at own risk etc. But if you want really quick and easy oauth and don't care much about configuration, here she is!

### 4. TODO

1. I'm adding the ability to bind to the event of getting the tokens, so you can store them in your database (they're still floating around on the req.session though, so you can always look there in the meantime)

2. Testing testing testing
1 change: 1 addition & 0 deletions node_modules/oauth/.npmignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions node_modules/oauth/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions node_modules/oauth/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 78 additions & 0 deletions node_modules/oauth/Readme.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

168 changes: 168 additions & 0 deletions node_modules/oauth/examples/express-gdata/server.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions node_modules/oauth/examples/express-gdata/views/layout.ejs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3816cd7

Please sign in to comment.