Quickstarts объясняет, как настроить и запустить приложение, вызывающее API Google Workspace. В этом quickstart используется упрощенный подход к аутентификации, подходящий для среды тестирования. Для производственной среды мы рекомендуем изучить аутентификацию и авторизацию, прежде чем выбирать учетные данные для доступа , подходящие для вашего приложения.
В Apps Script быстрые старты Google Workspace используют расширенные сервисы Google для вызова API Google Workspace и обработки некоторых деталей процесса аутентификации и авторизации.
/** * Print the display name if available for 10 connections. */functionlistConnectionNames(){try{/** * List the 10 connections/contacts of user * @see https://developers.google.com/people/api/rest/v1/people.connections/list */constconnections=People.People.Connections.list('people/me',{pageSize:10,personFields:'names,emailAddresses'// use other query parameter here if needed.});connections.connections.forEach((person)=>{// if contacts/connections is available, print the name of person.if(person.names && person.names.length===0){console.log('Nodisplaynamefoundforconnection.');return;}console.log(person.names[0].displayName);});}catch(err){// TODO (developer) - Handle exception from People APIconsole.log('Failedwitherror%s',err.message);}}
Нажмите «Сохранить». .
Щелкните «Проект без названия» , введите «Быстрый старт» и щелкните «Переименовать» .
Настроить скрипт
Включить API людей
Откройте проект Apps Script.
Нажмите Редакторcode .
Рядом с пунктом «Услуги» нажмите кнопку « add услугу».
Выберите API людей и нажмите Добавить .
Запустите образец
В редакторе скриптов приложений нажмите кнопку «Выполнить» .
При первом запуске образца вам будет предложено разрешить доступ:
Нажмите «Просмотреть разрешения» .
Выберите аккаунт.
Нажмите Разрешить .
Журнал выполнения скрипта отображается в нижней части окна.
[[["Прост для понимания","easyToUnderstand","thumb-up"],["Помог мне решить мою проблему","solvedMyProblem","thumb-up"],["Другое","otherUp","thumb-up"]],[["Отсутствует нужная мне информация","missingTheInformationINeed","thumb-down"],["Слишком сложен/слишком много шагов","tooComplicatedTooManySteps","thumb-down"],["Устарел","outOfDate","thumb-down"],["Проблема с переводом текста","translationIssue","thumb-down"],["Проблемы образцов/кода","samplesCodeIssue","thumb-down"],["Другое","otherDown","thumb-down"]],["Последнее обновление: 2025-07-02 UTC."],[[["This quickstart demonstrates how to use Google Apps Script to access the People API and retrieve a list of connections."],["Before starting, ensure you have a Google Workspace domain with API access enabled and a Google Account with administrator privileges."],["The guide walks you through creating, configuring, and running a script that prints the display names of your connections."],["You'll need to enable the People API in your Apps Script project and authorize the script to access your Google account."],["For production environments, Google recommends reviewing authentication and authorization best practices."]]],["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"]]