<commit_before>var express = require('express');

var app = express();
app.use(express.bodyParser());
app.use(express.cookieParser('sess'));

var PORT = process.argv[4] || 8553;

var fitbitClient = require('../')(process.argv[2], process.argv[3],
                                  'http://localhost:' + PORT);

var token;
app.get('/', function (req, res) {
  fitbitClient.getAccessToken(req, res, function (error, newToken) {
    if(newToken) {
      token = newToken;
      res.writeHead(200, {'Content-Type':'text/html'});
      res.end('<html>Now <a href="/getStuff">get stuff</a></html>');
    }
  });
});

app.get('/getStuff', function (req, res) {
  fitbitClient.apiCall('GET', '/user/-/activities/date/2011-05-25.json',
    {token: {oauth_token_secret: token.oauth_token_secret,
             oauth_token: token.oauth_token}},
    function(err, resp, json) {
      if (err) return res.send(err, 500);
      res.json(json);
  });
});

app.get('/cookie', function(req, res) {
  res.send('wahoo!');
});


app.listen(PORT);
console.log('listening at http://localhost:' + PORT + '/');<commit_msg>changed test to grab current auth'd user's profile<commit_after>var express = require('express');

var app = express();
app.use(express.bodyParser());
app.use(express.cookieParser('sess'));

var PORT = process.argv[5] || 8553;

var fitbitClient = require('../')(process.argv[2], process.argv[3],
                                  'http://localhost:' + PORT, process.argv[4]);

var token;
app.get('/', function (req, res) {
  fitbitClient.getAccessToken(req, res, function (error, newToken) {
    if(newToken) {
      token = newToken;
      res.writeHead(200, {'Content-Type':'text/html'});
      res.end('<html>Now <a href="/getStuff">get stuff</a></html>');
    }
  });
});

app.get('/getStuff', function (req, res) {
  fitbitClient.apiCall('GET', '/user/-/profile.json',
    {token: {oauth_token_secret: token.oauth_token_secret,
             oauth_token: token.oauth_token}},
    function(err, resp, json) {
      if (err) return res.send(err, 500);
      res.json(json);
  });
});

app.get('/cookie', function(req, res) {
  res.send('wahoo!');
});


app.listen(PORT);
console.log('listening at http://localhost:' + PORT + '/');
{'fraction_non_alphanumeric': 0.20367877972184836, 'fraction_numerical': 0.01570210856886496, 'mean_word_length': 3.495967741935484, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2589413', 'n_tokens_mistral': 786, 'n_tokens_neox': 752, 'n_words': 142}