<commit_before>googleToken = require '../utils/google_access_token'
importContacts = require '../utils/import_contacts'
importPhotos = require '../utils/import_photos'
importCalendar = require '../utils/import_calendar'
realtimer = require '../utils/realtimer'
syncGmail = require '../utils/sync_gmail'
async = require 'async'
log = require('printit')('leaveGcontroller')

module.exports.index = (req, res) ->
    url = googleToken.getAuthUrl()
    res.render 'index', imports: """
        window.oauthUrl = "#{url}";
    """

module.exports.lg = (req, res, next) ->

    res.send 200

    {auth_code, scope} = req.body
    #scope is like this :
    # scope: { photos: 'true', calendars: 'false', contacts: 'true'}
    # in this case we import only photos and contacts

    googleToken.generateRequestToken auth_code, (err, tokens) ->
        log.error err if err

        unless tokens?.access_token
            console.log "No access token"
            realtimer.sendEnd "invalid token"
            return<commit_msg>Add transmission of the to the client<commit_after>async = require 'async'
cozydb = require 'cozydb'
googleToken = require '../utils/google_access_token'
importCalendar = require '../utils/import_calendar'
importContacts = require '../utils/import_contacts'
importPhotos = require '../utils/import_photos'
log = require('printit')('leaveGcontroller')
realtimer = require '../utils/realtimer'
syncGmail = require '../utils/sync_gmail'

module.exports.index = (req, res) ->
    url = googleToken.getAuthUrl()
    cozydb.api.getCozyLocale (err, locale) ->
        res.render 'index', imports: """
            window.oauthUrl = "#{url}";
            window.locale = "#{locale}";
        """

module.exports.lg = (req, res, next) ->

    res.send 200

    {auth_code, scope} = req.body
    #scope is like this :
    # scope: { photos: 'true', calendars: 'false', contacts: 'true'}
    # in this case we import only photos and contacts

    googleToken.generateRequestToken auth_code, (err, tokens) ->
        log.error err if err

        unless tokens?.access_token
            console.log "No access token"
            realtimer.sendEnd "invalid token"
            return
{'fraction_non_alphanumeric': 0.13351623228166437, 'fraction_numerical': 0.0027434842249657062, 'mean_word_length': 3.066914498141264, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '1441836', 'n_tokens_mistral': 651, 'n_tokens_neox': 634, 'n_words': 173}