Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: llun/blog
base: 77c8086a9b
...
head fork: llun/blog
compare: f35bcc9c76
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 25 additions and 1 deletion.
  1. +25 −1 services/twitter.js
View
26 services/twitter.js
@@ -18,8 +18,32 @@ var Twitter = function (key, secret, url) {
'HMAC-SHA1');
}
-Twitter.prototype.authorizeUrl = function () {
+Twitter.secrets = {};
+Twitter.prototype.authorize = function (req, res) {
+ this.oauth.getOAuthRequestToken(function(error, oauth_token, oauth_token_secret, oauth_authorize_url, additionalParameters ) {
+ if(error) {
+ console.err( 'Error retrieving the OAuth Request Token: ' + JSON.stringify(error) );
+ res.redirect('/admin'); // Ignore the error upstream, treat as validation failure.
+ } else {
+ console.log ( 'Successfully retrieved the OAuth Request Token' );
+ Twitter.secrets[oauth_token] = oauth_token_secret;
+ res.redirect('http://twitter.com/oauth/authorize?oauth_token=' + oauth_token);
+ }
+ });
+}
+
+Twitter.prototype.callback = function (req, cb) {
+ this.oauth.getOAuthAccessToken(req.query.oauth_token,
+ Twitter.secrets[req.query.oauth_token], req.query.oauth_verifier,
+ function (err, token, secret, user) {
+ if (err) {
+ cb(err);
+ }
+ else {
+ cb(null, token + '|' + secret);
+ }
+ });
}
module.exports = Twitter;

No commit comments for this range

Something went wrong with that request. Please try again.