<commit_before>const Token = require('./database/models').Token;
const User = require('./database/models').User;
var google = require('googleapis');
var googleAuth = require('google-auth-library');
var SCOPES = ['https://www.googleapis.com/auth/calendar'];
var fs = require('fs');
var readline = require('readline');

function authorize(credentials, callback, token, event) {
  var clientSecret = credentials.installed.client_secret;
  var clientId = credentials.installed.client_id;
  var redirectUrl = credentials.installed.redirect_uris[0];
  var auth = new googleAuth();
  var oauth2Client = new auth.OAuth2(clientId, clientSecret, redirectUrl);
  console.log('tokeno', token)
  oauth2Client.credentials = JSON.parse(token.token);
  callback(oauth2Client, event);
}



//req.body includes:interviewerid, use toget interviewer email, start and end time
//roomname/jobposition room.job_position + room.owner_id
exports.createEvent = function(req, res) {
  var event = {
    'summary': req.body.job_position + ' interview for ' ,
    'location': 'localhost:3000/#/interviewroom?roomid=' + req.body.roomid,
    'description': 'Your first inner-view',
    'start': {
      'dateTime': new Date(req.body.start),
      'timeZone': 'America/Los_Angeles'
    },
    'end': {
      'dateTime': new Date(req.body.end),
      'timeZone': 'America/Los_Angeles'
    },
    'attendees': [
      {'email': '<EMAIL>'},
      {'email': '<EMAIL>'}
      ]
    }

  Token.find({where: {owner_id: req.body.interviewer_id}})
  .then(function(token) {
    if (!token) {
      console.log('error finding interviewer token')
      return;
    }
    fs.readFile('client_secret.json', function processClientSecrets(err, content) {
      if (err) {
        console.log('Error loading client secret file: ' + err);
        return;
      }
      // Authorize a client with the loaded credentials, then call the
      // Google Calendar API.
      authorize(JSON.parse(content), createEvento, token, event);//-------------------------------------this is done on server side
    });
    res.status(201).send();
  })
  .catch(function(err) {
    console.error(err);
    res.status(500).send(err);
  });
}





<commit_msg>kasonjims email for presentation<commit_after>const Token = require('./database/models').Token;
const User = require('./database/models').User;
var google = require('googleapis');
var googleAuth = require('google-auth-library');
var SCOPES = ['https://www.googleapis.com/auth/calendar'];
var fs = require('fs');
var readline = require('readline');

function authorize(credentials, callback, token, event) {
  var clientSecret = credentials.installed.client_secret;
  var clientId = credentials.installed.client_id;
  var redirectUrl = credentials.installed.redirect_uris[0];
  var auth = new googleAuth();
  var oauth2Client = new auth.OAuth2(clientId, clientSecret, redirectUrl);
  console.log('tokeno', token)
  oauth2Client.credentials = JSON.parse(token.token);
  callback(oauth2Client, event);
}



//req.body includes:interviewerid, use toget interviewer email, start and end time
//roomname/jobposition room.job_position + room.owner_id
exports.createEvent = function(req, res) {
  var event = {
    'summary': req.body.job_position + ' interview for ' ,
    'location': 'localhost:3000/#/interviewroom?roomid=' + req.body.roomid,
    'description': 'Your first inner-view',
    'start': {
      'dateTime': new Date(req.body.start),
      'timeZone': 'America/Los_Angeles'
    },
    'end': {
      'dateTime': new Date(req.body.end),
      'timeZone': 'America/Los_Angeles'
    },
    'attendees': [
      {'email': '<EMAIL>'},
      {'email': '<EMAIL>'}
      ]
    }

  Token.find({where: {owner_id: req.body.interviewer_id}})
  .then(function(token) {
    if (!token) {
      console.log('error finding interviewer token')
      return;
    }
    fs.readFile('client_secret.json', function processClientSecrets(err, content) {
      if (err) {
        console.log('Error loading client secret file: ' + err);
        return;
      }
      // Authorize a client with the loaded credentials, then call the
      // Google Calendar API.
      authorize(JSON.parse(content), createEvento, token, event);//-------------------------------------this is done on server side
    });
    res.status(201).send();
  })
  .catch(function(err) {
    console.error(err);
    res.status(500).send(err);
  });
}






{'fraction_non_alphanumeric': 0.16481271282633372, 'fraction_numerical': 0.00681044267877412, 'mean_word_length': 3.3537549407114624, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '7284821', 'n_tokens_mistral': 1381, 'n_tokens_neox': 1344, 'n_words': 297}