Created
February 17, 2020 16:55
-
-
Save ThomasKruegl/7f866a174231911fcc4690fa803d1d72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// original call | |
getCredentials(path.resolve(__dirname, "../../config/google_clientid.json")).then( async (content) => { | |
const buff_content = JSON.parse(content); | |
const accessData = await authorize(JSON.parse(content), syncdinfo); | |
const googleGroupData = await createGoogleGroup(accessData) | |
console.log("googleGroupData = " + JSON.stringify(googleGroupData)); | |
}); | |
// next call | |
async function authorize(credentials, accessData) { | |
// does a load of async calls out to db's and services to checks stuff then send cab call back two two different possibilities | |
// If the creds are there or not. If they are there it goes to the call | |
if (!accessData.Item.access_token) { | |
return getAccessToken(accessData); | |
} | |
return accessData; | |
} | |
async function getAccessToken(accessData) { | |
// does a load of stuff | |
return accessData; | |
} | |
async function createGoogleGroup ( auth , accessData ) { | |
const calendar = google.calendar({version: "v3", auth}); | |
/*console.log("Creating group in google to match ours"); | |
console.log("accessData at createGoogleGroup - " + JSON.stringify(accessData) );*/ | |
let googleCal = { | |
description: accessData.data.group_description, | |
summary: accessData.data.group_name, | |
} | |
console.log("googleCal at createGoogleGroup - " + JSON.stringify(googleCal) ); | |
let EGID = await calendar.calendars.insert({ | |
requestBody: googleCal, | |
}).catch(console.error); | |
console.log("EGID at createGoogleGroup - " + JSON.stringify(EGID) ); | |
return EGID; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment