<commit_before>const credentials = require('./credentials');
const Configstore = require('configstore');

const google = require('googleapis');
const OAuth2Client = google.auth.OAuth2;

const REDIRECT_URL = 'http://localhost:9000/youtube/callback';
const oauth2Client = new OAuth2Client(credentials.CLIENT_ID, credentials.CLIENT_SECRET, REDIRECT_URL);

const conf = new Configstore('Youtube');

// Check if the stored access token (if existing) is still working
module.exports.tryStoredAccessToken = function (cb) {
  if(!conf.get('tokens')) {
    return cb(true);
  }

  oauth2Client.setCredentials(conf.get('tokens'));

  google.youtube('v3').subscriptions.list({
    part: 'id',
    mine: true,
    auth: oauth2Client
  }, function (err, response) {
    if (err) return cb(true);

    // Refresh the access token<commit_msg>Change the name of the app to YouWatch<commit_after>const credentials = require('./credentials');
const Configstore = require('configstore');

const google = require('googleapis');
const OAuth2Client = google.auth.OAuth2;

const REDIRECT_URL = 'http://localhost:9000/youtube/callback';
const oauth2Client = new OAuth2Client(credentials.CLIENT_ID, credentials.CLIENT_SECRET, REDIRECT_URL);

const conf = new Configstore('YouWatch');

// Check if the stored access token (if existing) is still working
module.exports.tryStoredAccessToken = function (cb) {
  if(!conf.get('tokens')) {
    return cb(true);
  }

  oauth2Client.setCredentials(conf.get('tokens'));

  google.youtube('v3').subscriptions.list({
    part: 'id',
    mine: true,
    auth: oauth2Client
  }, function (err, response) {
    if (err) return cb(true);

    // Refresh the access token
{'fraction_non_alphanumeric': 0.13333333333333333, 'fraction_numerical': 0.013095238095238096, 'mean_word_length': 4.919014084507042, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '4466613', 'n_tokens_mistral': 526, 'n_tokens_neox': 514, 'n_words': 128}