Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
Automatice la creación de usuarios mediante la secuencia de comandos de aplicaciones de Google en el SDK de administración de Google

Quiero automatizar la creación de usuarios en google como administrador donde uso el script de la aplicación para hacerlo, sin embargo, a partir de la documentación que estoy leyendo, no estoy seguro de si lo estoy haciendo bien, ya que recibo algunos errores en mi código, como después de POST y el script no funciona.

 function createUsers() { const userjson = { "primaryEmail": "atest@example.com", "name": { "givenName": "afirstName", "familyName": "alastName" }, "suspended": false, "password": "pass2022", "hashFunction": "SHA-1", "changePasswordAtNextLogin": true, "ipWhitelisted": false, "orgUnitPath": "myOrgPath", }; const optionalArgs = { customer: 'my_customer', orderBy: 'email' }; POST https://admin.googleapis.com/admin/directory/v1/users try { const response = AdminDirectory.Users.list(optionalArgs); const users = response.users; //check if user exists if (!users || users.length === 0) //create new user return AdminDirectory.newUser(userjson); // Print user exists Logger.log('User Existing'); } catch (err) { // TODO (developer)- Handle exception from the Directory API Logger.log('Failed with error %s', err.message); } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Según la documentación oficial , si desea hacerlo con Google Apps Script, debe formatear su código de la siguiente manera:

 function createUsers() { const userInfo = { "primaryEmail": "jvd@domain.com", "name": { "givenName": "Jackie", "familyName": "VanDamme" }, "suspended": false, "password": "thisisasupersecret", "changePasswordAtNextLogin": true, "ipWhitelisted": false }; try{ AdminDirectory.Users.insert(userInfo); console.log("User added"); } catch(error){ const {code, message} = error.details; if(code === 409 && message === "Entity already exists."){ console.log("User already exists"); } else { console.log(`${code} - ${message}`); } } }

Si tiene alguna duda sobre cómo usar la carga útil de recursos de usuario, consulte la documentación oficial de la API REST .

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!