Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove need to specify a redirect url

  • Loading branch information...
commit abc4eec8aea128b0d1ec7b936b3838010fb13213 1 parent 3f5b893
@gerad gerad authored
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/twitter_client.js
View
7 lib/twitter_client.js
@@ -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}
@@ -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) {
@@ -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;

0 comments on commit abc4eec

Please sign in to comment.
Something went wrong with that request. Please try again.