Panduan memulai cepat menjelaskan cara menyiapkan dan menjalankan aplikasi yang memanggil Google Workspace API. Panduan memulai ini menggunakan pendekatan autentikasi yang disederhanakan dan sesuai untuk lingkungan pengujian. Untuk lingkungan produksi, sebaiknya pelajari
autentikasi dan otorisasi
sebelum
memilih kredensial akses
yang sesuai untuk aplikasi Anda.
Di Apps Script, panduan memulai Google Workspace menggunakan
Layanan Google lanjutan untuk memanggil
Google Workspace API dan menangani beberapa detail autentikasi
dan alur otorisasi.
/** * @typedef {Object} EmailAddress * @see https://developers.google.com/people/api/rest/v1/people#Person * @property {string} value * Note: This is a partial definition. *//** * @typedef {Object} Name * @see https://developers.google.com/people/api/rest/v1/people#Person * @property {string} displayName * Note: This is a partial definition. *//** * @typedef {Object} Person * @see https://developers.google.com/people/api/rest/v1/people#Person * @property {Name[]} names * @property {EmailAddress[]} [emailAddresses] * Note: This is a partial definition. *//** * @typedef {Object} Connection * @see https://developers.google.com/people/api/rest/v1/people.connections/list * @property {Person[]} connections * Note: This is a partial definition. *//** * Print the display name if available for 10 connections. */functionlistConnectionNames(){// Use the People API to list the connections of the logged in user.// See: https://developers.google.com/people/api/rest/v1/people.connections/listif(!People||!People.People||!People.People.Connections){thrownewError("People service not enabled.");}constconnections=People.People.Connections.list("people/me",{pageSize:10,personFields:"names,emailAddresses",});if(!connections.connections){console.log("No connections found.");return;}for(constpersonofconnections.connections){if(person.names&&
person.names.length > 0&&
person.names[0].displayName){console.log(person.names[0].displayName);}else{console.log("No display name found for connection.");}}}
Klik Simpan .
Klik Project tanpa judul, ketik
Quickstart, lalu klik Ganti nama.
Mengonfigurasi skrip
Mengaktifkan People API
Buka project Apps Script.
Klik Editorcode.
Di samping Layanan, klik Tambahkan layanan
add .
Pilih
People API
lalu klik Tambahkan.
Menjalankan contoh
Di editor Apps Script, klik Run.
Saat pertama kali dijalankan, contoh aplikasi meminta Anda untuk mengotorisasi akses:
Klik Tinjau izin.
Pilih akun.
Klik Izinkan.
Log eksekusi skrip akan muncul di bagian bawah jendela.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-11-28 UTC."],[],["This document guides users to create and run a Google Apps Script that interacts with the People API. It involves configuring a new script on `script.google.com`, replacing the script editor's content with provided code, saving, and renaming the project. Users must enable the People API as a service within the script and authorize access during the initial run. The script then lists the display names of 10 connections. Production environments need appropriate authentication credentials.\n"]]