Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Erstellen Sie ein Google Apps Script, das Anfragen an die People API sendet.
In den Kurzanleitungen wird erläutert, wie Sie eine App einrichten und ausführen, die eine Google Workspace API aufruft. In dieser Kurzanleitung wird ein vereinfachter Authentifizierungsansatz verwendet, der für eine Testumgebung geeignet ist. Für eine Produktionsumgebung empfehlen wir, sich mit Authentifizierung und Autorisierung vertraut zu machen, bevor Sie die Zugriffsdaten auswählen, die für Ihre App geeignet sind.
In Apps Script werden in Google Workspace-Schnellstarts erweiterte Google-Dienste verwendet, um Google Workspace APIs aufzurufen und einige Details des Authentifizierungs- und Autorisierungsablaufs zu verarbeiten.
/** * 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);}}
Klicken Sie auf „Speichern“ .
Klicken Sie auf Unbenanntes Projekt, geben Sie Schnellstart ein und klicken Sie auf Umbenennen.
Script konfigurieren
People API aktivieren
Öffnen Sie das Apps Script-Projekt.
Klicken Sie auf Editorcode.
Klicken Sie neben Dienste auf „Dienst hinzufügen“
add .
Wählen Sie „People API“ aus und klicken Sie auf Hinzufügen.
Beispiel ausführen
Klicken Sie im Apps Script-Editor auf Ausführen.
Wenn Sie das Beispiel zum ersten Mal ausführen, werden Sie aufgefordert, den Zugriff zu autorisieren:
Klicken Sie auf Berechtigungen ansehen.
Wählen Sie ein Konto aus.
Klicken Sie auf Zulassen.
Das Ausführungsprotokoll des Scripts wird unten im Fenster angezeigt.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-07-03 (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"]]