I am trying to create Google accounts using NodeJS and return the GoogleID to a file in the working directory. I have a JSON file created in my working directory and I also have the Auth credentials saved there as well. I can read in the JSON but am getting an error when the code is executed.
Error: Invalid Given/Family Name: FamilyName
Any help would be greatly appreciated.
Here is the code. (not including the Auth stuff above this, from: https://developers.google.com/admin-sdk/directory/v1/quickstart/nodejs#step_3_set_up_the_sample)
function listUsers(auth){
fs.readFile('user.json', function processClientSecrets(err, content) {
if (err) {
console.log('Error loading client secret file: ' + err);
return;
}
var newUser = JSON.parse(content);
console.log(newUser);
console.log(newUser.First);
console.log(newUser.Last);
var createUser = {
auth: auth,
"name": {
"givenName": newUser.First,
"familyName": newUser.Last
},
"password": "aPa$$w0rd",
"primaryEmail": newUser.District_Email,
"changePasswordAtNextLogin": false,
"orgUnitPath": "/Staff"
};
var admin = google.admin( "directory_v1");
var id = admin.users.insert(createUser).id;
fs.writeFile("gid.txt", "mcs" + id);
});
}