!7
html {
S redirect_uri = fullRawLink("/callback");
if (eq(uri, "/callback")) {
S code = assertNempty(params.get("code"));
Map tokenMap = googleAuthorizationCodeToTokens_raw(googleBotCompanyClientID(), googleBotCompanyClientSecret(), redirect_uri, code);
printStruct(tokenMap);
ret printAndProgramLog("We're back from Google! " + hpre(pnlToString(params)));
}
/*O json = decodeJSON(trimLoadMandatoryTextFile(javaxSecretDir("google-calendar/credentials.json")));
Map installed = cast get((Map) json, "installed");
S client_id = assertNempty("client_id", (S) get(installed, "client_id"));*/
S client_id = googleBotCompanyClientID();
S scope = "https://www.googleapis.com/auth/calendar";
ret hrefresh(2.0, print(googleOAuthRedirectURL(print(+redirect_uri), client_id, scope))) + "Redirecting to Google...";
}