Skip to content

Commit

Permalink
remove need to specify a redirect url
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerad Suyderhoud committed Mar 11, 2011
1 parent 3f5b893 commit abc4eec
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/twitter_client.js
Expand Up @@ -22,7 +22,7 @@ module.exports = function (api_key, api_secret, redirect) {
api_key,
api_secret,
'1.0',
redirect,
redirect || false,
'HMAC-SHA1',
null,
{'Accept': '*/*', 'Connection': 'close', 'User-Agent': 'twitter-js ' + client.version}
Expand Down Expand Up @@ -66,7 +66,9 @@ module.exports = function (api_key, api_secret, redirect) {

client.getAccessToken = function (req, res, callback) {

var parsedUrl = url.parse(req.url, true);
var parsedUrl = url.parse(req.url, true)
, protocol = (req.socket.encrypted ? 'https' : 'http' )
, callbackUrl = protocol + '://' + req.headers.host + parsedUrl.pathname;

// Acces token
if (parsedUrl.query && parsedUrl.query.oauth_token && req.session.auth && req.session.auth.twitter_oauth_token_secret) {
Expand All @@ -88,6 +90,7 @@ module.exports = function (api_key, api_secret, redirect) {
} else {

oAuth.getOAuthRequestToken(
{ oauth_callback: callbackUrl },
function (error, oauth_token, oauth_token_secret, oauth_authorize_url, additionalParameters) {
if (!error) {
req.session.twitter_redirect_url = req.url;
Expand Down

0 comments on commit abc4eec

Please sign in to comment.