I am using react-google-apps-script to implement a Google Apps Script UI for a spreadsheet.
I have code in my server implementation as
const getActiveUserEmail = () => {
return Session.getActiveUser().getEmail();
};
It is referenced from the client via:
import { getActiveUserEmail } from '../../../server';
const email = getActiveUserEmail();
After I deploy to a spreadsheet and run it, I get 'Session' undefined when the code is hit. I also get 'PropertiesService undefined' if that code is hit.
I'm able to use HtmlService, SpreadsheetApp, and UrlFetch apis without issue.
My appscript.json file contains
{
"timeZone": "America/New_York",
"dependencies": {},
"exceptionLogging": "STACKDRIVER",
"oauthScopes": [
"https://www.googleapis.com/auth/script.container.ui",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/userinfo.email"
],
"runtimeVersion": "V8"
}
Why are these undefined and how can I force them to be defined?
Update: Enushi has provided a working code example.