<commit_before>var gui = require('nw.gui'),
  OAuth = require('oauth'),
  gui = require('nw.gui');
var oauth = new OAuth.OAuth(
  "https://api.twitter.com/oauth/request_token",
  "https://api.twitter.com/oauth/access_token",
  "cY0UcnKfIW8dxtgSjsq6Q",
  "<KEY>",
  "1.0A",
  null,
  "HMAC-SHA1"
);
gui.Window.get().show();
oauth.getOAuthRequestToken(function(error, oauth_token, oauth_token_secret, results) {
  if (error) {
    console.log(error);
    res.send("yeah no. didn't work.")
  } else {
    //req.session.oauth = {};
    //req.session.oauth.token = oauth_token;
    console.log('oauth.token: ' + oauth_token);
    //req.session.oauth.token_secret = oauth_token_secret;
    console.log('oauth.token_secret: ' + oauth_token_secret);
    //res.redirect('https://twitter.com/oauth/authenticate?oauth_token=' + oauth_token)
    document.getElementById('keys').innerHTML = 'oauth.token: ' + oauth_token + 'oauth.token_secret: ' + oauth_token_secret;
  }
});<commit_msg>1. get access token and secret 2. get tweets<commit_after>var Twitter = require('twitter'),
  OAuth = require('oauth'),
  gui = require('nw.gui');
var twClient;
var twOauthParams = {
  consumer_key: "cY0UcnKfIW8dxtgSjsq6Q",
  consumer_secret: "<KEY>",
  access_token_key: "",
  access_token_secret: ""
}
var oauth = new OAuth.OAuth(
  "https://api.twitter.com/oauth/request_token",
  "https://api.twitter.com/oauth/access_token",
  twOauthParams.consumer_key,
  twOauthParams.consumer_secret,
  "1.0A",
  "oob",
  "HMAC-SHA1"
);
var newWindow = function(url, params) {
  var tmpWin;
  if (!url || url === "") {
    return null;
  }
  if (!params) {
    params = {
      toolbar: true,
      resizable: true,
      show: true,
      height: 500,
      width: 500
    }
  }
  tmpWin = gui.Window.open(url, params);
  return tmpWin;
};
var getTweets = function() {
  var params;
  console.log(twOauthParams);
  if (!twClient) {
    twClient = new Twitter(twOauthParams);
  }
  params = {
    screen_name: 'winneras' //need to use '', "" will not work
  };
  twClient.get('statuses/user_timeline', params, function(error, tweets, response) {
    if (!error) {
      console.log(tweets);
    }
  });
};
var accessTokenHandler = function(error, accessToken, accessTokenSecret, results) {
  if (error) {
    console.log(error);
    res.send("yeah no. didn't work.")
  } else {
    twOauthParams.access_token_key = accessToken;
    twOauthParams.access_token_secret = accessTokenSecret;
  }
  getTweets();
};
var getAccessToken = function(token, secret, pin) {
  oauth.getOAuthAccessToken(token, secret, pin, accessTokenHandler);
};
var oauthRequestTokenHandler = function(error, oauth_token, oauth_token_secret, results) {
  var twPinWin, oauthUrl, twPin, getPinHandle;
  if (error) {
    console.log(error);
    res.send("yeah no. didn't work.")
  } else {
    console.log('oauth.token: ' + oauth_token);
    console.log('oauth.token_secret: ' + oauth_token_secret);
    oauthUrl = 'https://twitter.com/oauth/authenticate?oauth_token=' + oauth_token
    document.getElementById('keys').innerHTML = 'oauth.token: ' + oauth_token + '<br>oauth.token_secret: ' + oauth_token_secret;
    twPinWin = newWindow(oauthUrl);
    getPinHandle = window.setInterval(function() {
      console.log(twPinWin);
      twPin = twPinWin.window.document.getElementsByTagName("code");
      if (twPin.length === 1) {
        window.clearInterval(getPinHandle);
        twPin = twPin[0].innerHTML;
        console.log(twPin);
        getAccessToken(oauth_token, oauth_token_secret, twPin);
      }
    }, 2000);
  }
}


gui.Window.get().show();
oauth.getOAuthRequestToken(oauthRequestTokenHandler);
{'fraction_non_alphanumeric': 0.1539517014270033, 'fraction_numerical': 0.007135016465422613, 'mean_word_length': 3.8535286284953396, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6279034', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1307, 'n_words': 219}