![](/img/trans.png)
[英]How to have google docs api (nodejs) create an empty doc in a particular google account
[英]How to create google user account in NodeJS?
我正在嘗試使用NodeJS創建Google帳戶,並將GoogleID返回到工作目錄中的文件。 我在工作目錄中創建了一個JSON文件,並且我還保存了Auth憑據。 我可以讀取JSON,但是執行代碼時出現錯誤。
錯誤:給定的/姓氏無效:FamilyName
任何幫助將不勝感激。
這是代碼。 (不包括上述內容中的Auth內容,來自: 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);
});
}
var createUser = { auth: auth, resource: { "name": { "givenName": newUser.First, "familyName": newUser.Last }, "password": "mcs12345", "primaryEmail": newUser.District_Email, "changePasswordAtNextLogin": false, "orgUnitPath": "/Staff" } };
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.