Permalink
Browse files

Document Twitter strategy.

  • Loading branch information...
1 parent 8322878 commit 9e3f782c0391e27e18f5cf2c6ab269ca9933db39 @jaredhanson jaredhanson committed Oct 17, 2011
Showing with 36 additions and 1 deletion.
  1. +36 −1 lib/passport-twitter/strategy.js
@@ -2,12 +2,41 @@
* Module dependencies.
*/
var util = require('util')
- , OAuthStrategy = require("passport-oauth").OAuthStrategy;
+ , OAuthStrategy = require('passport-oauth').OAuthStrategy;
/**
* `Strategy` constructor.
*
+ * The Twitter authentication strategy authenticates requests by delegating to
+ * Twitter using the OAuth protocol.
+ *
+ * Applications must supply a `verify` callback which accepts a `token`,
+ * `tokenSecret` and service-specific `info`, and then calls the `done` callback
+ * supplying a `user`, which should be set to `false` if the credentials are not
+ * valid. If an exception occured, `err` should be set.
+ *
+ * Options:
+ * - `consumerKey` identifies client to Twitter
+ * - `consumerSecret` secret used to establish ownership of the consumer key
+ * - `callbackURL` URL to which Twitter will redirect the user after obtaining authorization
+ *
+ * Examples:
+ *
+ * passport.use(new TwitterStrategy({
+ * consumerKey: '123-456-789',
+ * consumerSecret: 'shhh-its-a-secret'
+ * callbackURL: 'https://www.example.net/auth/twitter/callback'
+ * },
+ * function(token, tokenSecret, info, done) {
+ * User.findOrCreate(..., function (err, user) {
+ * done(err, user);
+ * });
+ * }
+ * ));
+ *
+ * @param {Object} options
+ * @param {Function} verify
* @api public
*/
function Strategy(options, verify) {
@@ -27,6 +56,12 @@ function Strategy(options, verify) {
util.inherits(Strategy, OAuthStrategy);
+/**
+ * Authenticate request by delegating to Twitter using OAuth.
+ *
+ * @param {Object} req
+ * @api protected
+ */
Strategy.prototype.authenticate = function(req) {
// When a user denies authorization on Twitter, they are presented with a link
// to return to the application in the following format (where xxx is the

0 comments on commit 9e3f782

Please sign in to comment.