Showing preview only (458K chars total). Download the full file or copy to clipboard to get everything.
Repository: googleworkspace/node-samples
Branch: main
Commit: dc39b4f4dca7
Files: 290
Total size: 389.7 KB
Directory structure:
gitextract_b64kqjz8/
├── .gemini/
│ ├── GEMINI.md
│ ├── config.yaml
│ └── settings.json
├── .github/
│ ├── CODEOWNERS
│ ├── ISSUE_TEMPLATE.md
│ ├── dependabot.yml
│ ├── snippet-bot.yml
│ ├── sync-repo-settings.yaml
│ └── workflows/
│ ├── automation.yml
│ ├── lint.yml
│ └── test.yml
├── .gitignore
├── .vscode/
│ └── extensions.json
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── SECURITY.md
├── adminSDK/
│ ├── directory/
│ │ ├── index.js
│ │ ├── package.json
│ │ └── tsconfig.json
│ ├── reports/
│ │ ├── index.js
│ │ ├── package.json
│ │ └── tsconfig.json
│ └── reseller/
│ ├── index.js
│ ├── package.json
│ └── tsconfig.json
├── apps-script/
│ ├── execute/
│ │ ├── index.js
│ │ ├── package.json
│ │ └── tsconfig.json
│ └── quickstart/
│ ├── index.js
│ ├── package.json
│ └── tsconfig.json
├── biome.json
├── calendar/
│ └── quickstart/
│ ├── index.js
│ ├── package.json
│ └── tsconfig.json
├── chat/
│ ├── client-libraries/
│ │ └── cloud/
│ │ ├── authentication-utils.js
│ │ ├── create-custom-emoji-user-cred.js
│ │ ├── create-membership-user-cred-for-app.js
│ │ ├── create-membership-user-cred-for-group.js
│ │ ├── create-membership-user-cred.js
│ │ ├── create-message-app-cred.js
│ │ ├── create-message-user-cred-at-mention.js
│ │ ├── create-message-user-cred-message-id.js
│ │ ├── create-message-user-cred-request-id.js
│ │ ├── create-message-user-cred-thread-key.js
│ │ ├── create-message-user-cred-thread-name.js
│ │ ├── create-message-user-cred.js
│ │ ├── create-reaction-user-cred.js
│ │ ├── create-space-user-cred.js
│ │ ├── delete-custom-emoji-user-cred.js
│ │ ├── delete-membership-user-cred.js
│ │ ├── delete-message-app-cred.js
│ │ ├── delete-message-user-cred.js
│ │ ├── delete-reaction-user-cred.js
│ │ ├── delete-space-user-cred.js
│ │ ├── find-dm-space-app-cred.js
│ │ ├── find-dm-space-user-cred.js
│ │ ├── get-attachment-app-cred.js
│ │ ├── get-custom-emoji-user-cred.js
│ │ ├── get-membership-app-cred.js
│ │ ├── get-membership-user-cred.js
│ │ ├── get-message-app-cred.js
│ │ ├── get-message-user-cred.js
│ │ ├── get-space-app-cred.js
│ │ ├── get-space-event-user-cred.js
│ │ ├── get-space-notification-setting-user-cred.js
│ │ ├── get-space-read-state-user-cred.js
│ │ ├── get-space-user-cred.js
│ │ ├── get-thread-read-state-user-cred.js
│ │ ├── list-custom-emojis-user-cred.js
│ │ ├── list-memberships-app-cred.js
│ │ ├── list-memberships-user-cred.js
│ │ ├── list-messages-user-cred.js
│ │ ├── list-reactions-user-cred.js
│ │ ├── list-space-events-user-cred.js
│ │ ├── list-spaces-app-cred.js
│ │ ├── list-spaces-user-cred.js
│ │ ├── package.json
│ │ ├── set-up-space-user-cred.js
│ │ ├── tsconfig.json
│ │ ├── update-membership-user-cred.js
│ │ ├── update-message-app-cred.js
│ │ ├── update-message-user-cred.js
│ │ ├── update-space-notification-setting-user-cred.js
│ │ ├── update-space-read-state-user-cred.js
│ │ └── update-space-user-cred.js
│ └── quickstart/
│ ├── index.js
│ ├── package.json
│ └── tsconfig.json
├── classroom/
│ └── quickstart/
│ ├── index.js
│ ├── package.json
│ └── tsconfig.json
├── docs/
│ └── quickstart/
│ ├── index.js
│ ├── package.json
│ └── tsconfig.json
├── drive/
│ ├── activity-v2/
│ │ ├── index.js
│ │ ├── package.json
│ │ └── tsconfig.json
│ ├── quickstart/
│ │ ├── index.js
│ │ ├── package.json
│ │ └── tsconfig.json
│ └── snippets/
│ ├── drive_v2/
│ │ ├── appdata_snippets/
│ │ │ ├── fetch_appdata_folder.js
│ │ │ ├── list_appdata.js
│ │ │ ├── package.json
│ │ │ ├── tsconfig.json
│ │ │ └── upload_appdata.js
│ │ ├── change_snippets/
│ │ │ ├── fetch_changes.js
│ │ │ ├── fetch_start_page_token.js
│ │ │ ├── package.json
│ │ │ └── tsconfig.json
│ │ ├── drive_snippets/
│ │ │ ├── create_drive.js
│ │ │ ├── package.json
│ │ │ ├── recover_drives.js
│ │ │ └── tsconfig.json
│ │ └── file snippets/
│ │ ├── create_folder.js
│ │ ├── create_shortcut.js
│ │ ├── download_file.js
│ │ ├── export_pdf.js
│ │ ├── move_file_to_folder.js
│ │ ├── package.json
│ │ ├── search_file.js
│ │ ├── share_file.js
│ │ ├── touch_file.js
│ │ ├── tsconfig.json
│ │ ├── upload_basic.js
│ │ ├── upload_to_folder.js
│ │ └── upload_with_conversion.js
│ ├── drive_v3/
│ │ ├── appdata_snippets/
│ │ │ ├── fetch_appdata_folder.js
│ │ │ ├── list_appdata.js
│ │ │ ├── package.json
│ │ │ ├── tsconfig.json
│ │ │ └── upload_appdata.js
│ │ ├── change_snippets/
│ │ │ ├── fetch_changes.js
│ │ │ ├── fetch_start_page_token.js
│ │ │ ├── package.json
│ │ │ └── tsconfig.json
│ │ ├── drive_snippets/
│ │ │ ├── create_drive.js
│ │ │ ├── package.json
│ │ │ ├── recover_drives.js
│ │ │ └── tsconfig.json
│ │ └── file_snippets/
│ │ ├── create_folder.js
│ │ ├── create_shortcut.js
│ │ ├── download_file.js
│ │ ├── export_pdf.js
│ │ ├── move_file_to_folder.js
│ │ ├── package.json
│ │ ├── search_file.js
│ │ ├── share_file.js
│ │ ├── touch_file.js
│ │ ├── tsconfig.json
│ │ ├── upload_basic.js
│ │ ├── upload_to_folder.js
│ │ └── upload_with_conversion.js
│ ├── files/
│ │ ├── config.json
│ │ ├── document.txt
│ │ └── report.csv
│ └── test/
│ ├── helpers.js
│ ├── test_drive_v2_create_drive.js
│ ├── test_drive_v2_create_folder.js
│ ├── test_drive_v2_create_shortcut.js
│ ├── test_drive_v2_download_file.js
│ ├── test_drive_v2_export_pdf.js
│ ├── test_drive_v2_fetch_appdata_folder.js
│ ├── test_drive_v2_fetch_changes.js
│ ├── test_drive_v2_fetch_start_page_token.js
│ ├── test_drive_v2_list_appdata.js
│ ├── test_drive_v2_move_file_to_folder.js
│ ├── test_drive_v2_recover_drives.js
│ ├── test_drive_v2_search_file.js
│ ├── test_drive_v2_share_file.js
│ ├── test_drive_v2_touch_file.js
│ ├── test_drive_v2_upload_appdata.js
│ ├── test_drive_v2_upload_basic.js
│ ├── test_drive_v2_upload_to_folder.js
│ ├── test_drive_v2_upload_with_conversion.js
│ ├── test_drive_v3_create_drive.js
│ ├── test_drive_v3_create_folder.js
│ ├── test_drive_v3_create_shortcut.js
│ ├── test_drive_v3_download_file.js
│ ├── test_drive_v3_export_pdf.js
│ ├── test_drive_v3_fetch_appdata_folder.js
│ ├── test_drive_v3_fetch_changes.js
│ ├── test_drive_v3_fetch_start_page_token.js
│ ├── test_drive_v3_list_appdata.js
│ ├── test_drive_v3_move_file_to_folder.js
│ ├── test_drive_v3_recover_drives.js
│ ├── test_drive_v3_search_file.js
│ ├── test_drive_v3_share_file.js
│ ├── test_drive_v3_touch_file.js
│ ├── test_drive_v3_upload_appdata.js
│ ├── test_drive_v3_upload_basic.js
│ ├── test_drive_v3_upload_to_folder.js
│ └── test_drive_v3_upload_with_conversion.js
├── forms/
│ └── snippets/
│ ├── add_item.js
│ ├── add_responder.js
│ ├── anyone_with_link_responder.js
│ ├── convert_form.js
│ ├── create_form.js
│ ├── create_watch.js
│ ├── delete_watch.js
│ ├── get_all_responses.js
│ ├── get_form.js
│ ├── get_responders.js
│ ├── get_single_response.js
│ ├── list_watches.js
│ ├── package.json
│ ├── publish_form.js
│ ├── remove_responders.js
│ ├── renew_watch.js
│ ├── stop_accepting_responses.js
│ ├── supports_publishing.js
│ ├── tsconfig.json
│ ├── unpublish_form.js
│ └── update_form.js
├── gmail/
│ └── quickstart/
│ ├── index.js
│ ├── package.json
│ └── tsconfig.json
├── meet/
│ ├── README.md
│ └── quickstart/
│ ├── index.js
│ ├── package.json
│ └── tsconfig.json
├── package.json
├── people/
│ └── quickstart/
│ ├── index.js
│ ├── package.json
│ └── tsconfig.json
├── pnpm-workspace.yaml
├── sheets/
│ ├── quickstart/
│ │ ├── index.js
│ │ ├── package.json
│ │ └── tsconfig.json
│ └── snippets/
│ ├── package.json
│ ├── sheets_append_values.js
│ ├── sheets_batch_get_values.js
│ ├── sheets_batch_update.js
│ ├── sheets_batch_update_values.js
│ ├── sheets_conditional_formatting.js
│ ├── sheets_create.js
│ ├── sheets_get_values.js
│ ├── sheets_pivot_table.js
│ ├── sheets_update_values.js
│ ├── test/
│ │ ├── helpers.js
│ │ ├── test_sheets_append_values.js
│ │ ├── test_sheets_batch_get_values.js
│ │ ├── test_sheets_batch_update.js
│ │ ├── test_sheets_batch_update_values.js
│ │ ├── test_sheets_conditional_formatting.js
│ │ ├── test_sheets_create.js
│ │ ├── test_sheets_get_values.js
│ │ ├── test_sheets_pivot_table.js
│ │ └── test_sheets_update_values.js
│ └── tsconfig.json
├── slides/
│ ├── quickstart/
│ │ ├── index.js
│ │ ├── package.json
│ │ └── tsconfig.json
│ └── snippets/
│ ├── package.json
│ ├── slides_copy_presentation.js
│ ├── slides_create_bulleted_text.js
│ ├── slides_create_image.js
│ ├── slides_create_presentation.js
│ ├── slides_create_sheets_chart.js
│ ├── slides_create_slide.js
│ ├── slides_create_textbox_with_text.js
│ ├── slides_image_merging.js
│ ├── slides_refresh_sheets_chart.js
│ ├── slides_simple_text_replace.js
│ ├── slides_text_merging.js
│ ├── slides_text_style_update.js
│ ├── test/
│ │ ├── helpers.js
│ │ ├── test_slides_copy_presentation.js
│ │ ├── test_slides_create_bulleted_text.js
│ │ ├── test_slides_create_image.js
│ │ ├── test_slides_create_presentation.js
│ │ ├── test_slides_create_sheets_chart.js
│ │ ├── test_slides_create_slide.js
│ │ ├── test_slides_create_textbox_with_text.js
│ │ ├── test_slides_image_merging.js
│ │ ├── test_slides_refresh_sheets_chart.js
│ │ ├── test_slides_simple_text_replace.js
│ │ ├── test_slides_text_merging.js
│ │ └── test_slides_text_style_update.js
│ └── tsconfig.json
├── solutions/
│ └── webhook-chat-app/
│ ├── README.md
│ ├── index.js
│ ├── package.json
│ └── thread-reply.js
├── tasks/
│ └── quickstart/
│ ├── index.js
│ ├── package.json
│ └── tsconfig.json
├── tsconfig.base.json
└── turbo.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .gemini/GEMINI.md
================================================
# Overview
This codebase is part of the Google Workspace GitHub organization, https://github.com/googleworkspace.
## Style Guide
Use open source best practices for code style and formatting with a preference for Google's style guides.
## Tools
- Verify against Google Workspace documentation with the `workspace-developer` MCP server tools.
- Use `gh` for GitHub interactions.
================================================
FILE: .gemini/config.yaml
================================================
# Config for the Gemini Pull Request Review Bot.
# https://github.com/marketplace/gemini-code-assist
have_fun: false
code_review:
disable: false
comment_severity_threshold: "HIGH"
max_review_comments: -1
pull_request_opened:
help: false
summary: true
code_review: true
ignore_patterns: []
================================================
FILE: .gemini/settings.json
================================================
{
"mcpServers": {
"workspace-developer": {
"httpUrl": "https://workspace-developer.goog/mcp",
"trust": true
}
}
}
================================================
FILE: .github/CODEOWNERS
================================================
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
.github/ @googleworkspace/workspace-devrel-dpe
================================================
FILE: .github/ISSUE_TEMPLATE.md
================================================
# Summary
TODO
## Expected Behavior
Sample URL:
Description:
## Actual Behavior
## Steps to Reproduce the Problem
1.
1.
1.
================================================
FILE: .github/dependabot.yml
================================================
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "chore(deps):"
# For pnpm with a catalog, we want to update the versions in the manifest files.
versioning-strategy: increase
groups:
# Group all dependencies into a single PR.
all-deps:
patterns:
- "*"
================================================
FILE: .github/snippet-bot.yml
================================================
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
================================================
FILE: .github/sync-repo-settings.yaml
================================================
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# .github/sync-repo-settings.yaml
# See https://github.com/googleapis/repo-automation-bots/tree/main/packages/sync-repo-settings for app options.
rebaseMergeAllowed: true
squashMergeAllowed: true
mergeCommitAllowed: false
deleteBranchOnMerge: true
branchProtectionRules:
- pattern: main
isAdminEnforced: false
requiresStrictStatusChecks: false
requiredStatusCheckContexts:
# .github/workflows/test.yml with a job called "test"
- "test"
# .github/workflows/lint.yml with a job called "lint"
- "lint"
# Google bots below
- "cla/google"
- "snippet-bot check"
- "header-check"
- "conventionalcommits.org"
requiredApprovingReviewCount: 1
requiresCodeOwnerReviews: true
permissionRules:
- team: workspace-devrel-dpe
permission: admin
- team: workspace-devrel
permission: push
================================================
FILE: .github/workflows/automation.yml
================================================
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
name: Automation
on: [ push, pull_request, workflow_dispatch ]
jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request' }}
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GOOGLEWORKSPACE_BOT_TOKEN}}
steps:
- name: approve
run: gh pr review --approve "$PR_URL"
- name: merge
run: gh pr merge --auto --squash --delete-branch "$PR_URL"
default-branch-migration:
# this job helps with migrating the default branch to main
# it pushes main to master if master exists and main is the default branch
# it pushes master to main if master is the default branch
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
# required otherwise GitHub blocks infinite loops in pushes originating in an action
token: ${{ secrets.GOOGLEWORKSPACE_BOT_TOKEN }}
- name: Set env
run: |
# set DEFAULT BRANCH
echo "DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name')" >> "$GITHUB_ENV";
# set HAS_MASTER_BRANCH
if [ -n "$(git ls-remote --heads origin master)" ]; then
echo "HAS_MASTER_BRANCH=true" >> "$GITHUB_ENV"
else
echo "HAS_MASTER_BRANCH=false" >> "$GITHUB_ENV"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: configure git
run: |
git config --global user.name 'googleworkspace-bot'
git config --global user.email 'googleworkspace-bot@google.com'
- if: ${{ env.DEFAULT_BRANCH == 'main' && env.HAS_MASTER_BRANCH == 'true' }}
name: Update master branch from main
run: |
git checkout -B master
git reset --hard origin/main
git push origin master
- if: ${{ env.DEFAULT_BRANCH == 'master'}}
name: Update main branch from master
run: |
git checkout -B main
git reset --hard origin/master
git push origin main
================================================
FILE: .github/workflows/lint.yml
================================================
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
name: Lint
on:
push:
branches:
- main
pull_request:
jobs:
lint:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.0.0
with:
fetch-depth: 0
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
cache: 'pnpm'
- run: pnpm i
- run: pnpm lint
================================================
FILE: .github/workflows/test.yml
================================================
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Test
on:
push:
branches:
- main
pull_request:
jobs:
test:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
cache: "pnpm"
- run: pnpm i
- run: pnpm check
# Tests are failing due to scope/grant errors.
# - name: Write test credentials
# run: |
# mkdir "${HOME}/secrets"
# echo "${DEFAULT_CREDENTIALS}" > "${HOME}/secrets/default_credentials.json"
# echo "${SERVICE_ACCOUNT_CREDENTIALS}" > "${HOME}/secrets/service_account.json"
# echo "${CLIENT_ID_FILE}" > "${HOME}/secrets/client_id.json"
# env:
# DEFAULT_CREDENTIALS: ${{secrets.SNIPPETS_DEFAULT_CREDENTIALS}}
# SERVICE_ACCOUNT_CREDENTIALS: ${{secrets.SNIPPETS_DELEGATED_ADMIN_SERVICE_ACCOUNT}}
# CLIENT_ID_FILE: ${{secrets.SNIPPETS_CLIENT_ID_FILE}}
# - name: Run tests
# run: |
# export GOOGLE_APPLICATION_CREDENTIALS="${HOME}/secrets/default_credentials.json"
# export SERVICE_ACCOUNT_CREDENTIALS="${HOME}/secrets/service_account.json"
# pnpm test
# env:
# GOOGLE_CLOUD_PROJECT: workspace-samples-ci
================================================
FILE: .gitignore
================================================
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.lock
# Dependency directories
node_modules/
# dotenv environment variables file
.env
.DS_Store
client_secret.json
application_credentials.json
credentials.json
token.json
.turbo
================================================
FILE: .vscode/extensions.json
================================================
{
"recommendations": [
"google-workspace.google-workspace-developer-tools"
]
}
================================================
FILE: CONTRIBUTING.md
================================================
# How to become a contributor and submit your own code
## Contributor License Agreements
We'd love to accept your sample apps and patches! Before we can take them, we
have to jump a couple of legal hurdles.
Please fill out either the individual or corporate Contributor License Agreement
(CLA).
* If you are an individual writing original source code and you're sure you
own the intellectual property, then you'll need to sign an
[individual CLA](https://developers.google.com/open-source/cla/individual).
* If you work for a company that wants to allow you to contribute your work,
then you'll need to sign a
[corporate CLA](https://developers.google.com/open-source/cla/corporate).
Follow either of the two links above to access the appropriate CLA and
instructions for how to sign and return it. Once we receive it, we'll be able to
accept your pull requests.
## Contributing A Patch
1. Submit an issue describing your proposed change to the repository in question.
1. The repository owner will respond to your issue promptly.
1. If your proposed change is accepted, and you haven't already done so, sign a Contributor License Agreement (see details above).
1. Fork the desired repository, develop and test your code changes.
1. Ensure that your code adheres to the existing style in the sample to which you are contributing.
1. Ensure that your code has an appropriate set of unit tests which all pass.
1. Submit a pull request!
## Style
Samples in this repository follow the [JavaScript Semi-Standard
Style](https://github.com/Flet/semistandard).
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: README.md
================================================
# Node.js samples for [Google Workspace APIs](https://developers.google.com/workspace/) docs
This repository contains Node.js samples for Google Workspace APIs.
## Development
1. Install [Node.js](https://nodejs.org).
1. Install `pnpm` by running `npm install -g pnpm` or see additional options at https://pnpm.io/installation.
`pnpm` is used with `turborepo` to better handled the many packages in the repository.
1. Create a Service Account
Before running tests, create a service account and download `application_credentials.json` in this directory.
To create a service account, follow these steps:
1. Navigate to the [Google Cloud Console API Dashboard](https://console.cloud.google.com/apis/dashboard)
1. Enable APIs for products you'd like to test snippets for like Slides or Drive.
1. Create a service account key under [Credentials](https://console.cloud.google.com/apis/credentials).
1. After creating a new JSON Service account key without a role and set the env variable `SERVICE_ACCOUNT_CREDENTIALS=some/path/to/application_credentials.json`.
1. `pnpm test`
1. `pnpm lint`
1. Delete service account file.
1. `pnpx codemod pnpm/catalog` to add package dependencies to the catalog.
1. `pnpm -r -L update` to update all package depencies to the latest version.
## Contributing
Contributions welcome! See the [Contributing Guide](CONTRIBUTING.md).
================================================
FILE: SECURITY.md
================================================
# Report a security issue
To report a security issue, please use [https://g.co/vulnz](https://g.co/vulnz). We use
[https://g.co/vulnz](https://g.co/vulnz) for our intake, and do coordination and disclosure here on
GitHub (including using GitHub Security Advisory). The Google Security Team will
respond within 5 working days of your report on [https://g.co/vulnz](https://g.co/vulnz).
================================================
FILE: adminSDK/directory/index.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START admin_sdk_directory_quickstart]
import path from 'node:path';
import process from 'node:process';
import {authenticate} from '@google-cloud/local-auth';
import {google} from 'googleapis';
// The scope for the Admin SDK Directory API.
const SCOPES = ['https://www.googleapis.com/auth/admin.directory.user'];
// The path to the credentials file.
const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
/**
* Lists the first 10 users in the domain.
*/
async function listUsers() {
// Authenticate with Google and get an authorized client.
const auth = await authenticate({
scopes: SCOPES,
keyfilePath: CREDENTIALS_PATH,
});
// Create a new Admin SDK Directory API client.
const service = google.admin({version: 'directory_v1', auth});
// Get the list of users.
const result = await service.users.list({
customer: 'my_customer',
maxResults: 10,
orderBy: 'email',
});
const users = result.data.users;
if (!users || users.length === 0) {
console.log('No users found.');
return;
}
// Print the primary email and full name of each user.
console.log('Users:');
users.forEach((user) => {
console.log(`${user.primaryEmail} (${user.name?.fullName})`);
});
}
await listUsers();
// [END admin_sdk_directory_quickstart]
================================================
FILE: adminSDK/directory/package.json
================================================
{
"name": "google-admin-directory-nodejs-quickstart",
"version": "1.0.0",
"private": true,
"description": "A simple Node.js command-line application that makes requests to the Google Drive API.",
"license": "Apache-2.0",
"type": "module",
"scripts": {
"check": "tsc --noEmit"
},
"dependencies": {
"@google-cloud/local-auth": "catalog:",
"googleapis": "catalog:"
},
"devDependencies": {
"google-auth-library": "catalog:",
"typescript": "catalog:"
},
"engines": {
"node": ">=20"
}
}
================================================
FILE: adminSDK/directory/tsconfig.json
================================================
{
"extends": "../../tsconfig.base.json",
"include": ["**/*.js"]
}
================================================
FILE: adminSDK/reports/index.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START admin_sdk_reports_quickstart]
import path from 'node:path';
import process from 'node:process';
import {authenticate} from '@google-cloud/local-auth';
import {google} from 'googleapis';
// The scope for the Admin SDK Reports API.
const SCOPES = ['https://www.googleapis.com/auth/admin.reports.audit.readonly'];
// The path to the credentials file.
const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
/**
* Lists the last 10 login events for the domain.
*/
async function listLoginEvents() {
// Authenticate with Google and get an authorized client.
const auth = await authenticate({
scopes: SCOPES,
keyfilePath: CREDENTIALS_PATH,
});
// Create a new Admin SDK Reports API client.
const service = google.admin({version: 'reports_v1', auth});
// Get the list of login events.
const result = await service.activities.list({
userKey: 'all',
applicationName: 'login',
maxResults: 10,
});
const activities = result.data.items;
if (!activities || activities.length === 0) {
console.log('No logins found.');
return;
}
// Print the time, email, and event name of each login event.
console.log('Logins:');
activities.forEach((activity) => {
console.log(
`${activity.id?.time}: ${activity.actor?.email} (${activity.events?.[0]?.name})`,
);
});
}
await listLoginEvents();
// [END admin_sdk_reports_quickstart]
================================================
FILE: adminSDK/reports/package.json
================================================
{
"name": "google-admin-reports-nodejs-quickstart",
"version": "1.0.0",
"private": true,
"description": "A simple Node.js command-line application that makes requests to the Google Drive API.",
"license": "Apache-2.0",
"type": "module",
"scripts": {
"check": "tsc --noEmit"
},
"dependencies": {
"@google-cloud/local-auth": "catalog:",
"googleapis": "catalog:"
},
"devDependencies": {
"google-auth-library": "catalog:",
"typescript": "catalog:"
},
"engines": {
"node": ">=20"
}
}
================================================
FILE: adminSDK/reports/tsconfig.json
================================================
{
"extends": "../../tsconfig.base.json",
"include": ["**/*.js"]
}
================================================
FILE: adminSDK/reseller/index.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START admin_sdk_reseller_quickstart]
import path from 'node:path';
import process from 'node:process';
import {authenticate} from '@google-cloud/local-auth';
import {google} from 'googleapis';
// The scope for the Admin SDK Reseller API.
const SCOPES = ['https://www.googleapis.com/auth/apps.order'];
// The path to the credentials file.
const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
/**
* Lists the first 10 subscriptions you manage.
*/
async function listSubscriptions() {
// Authenticate with Google and get an authorized client.
const auth = await authenticate({
scopes: SCOPES,
keyfilePath: CREDENTIALS_PATH,
});
// Create a new Admin SDK Reseller API client.
const service = google.reseller({version: 'v1', auth});
// Get the list of subscriptions.
const result = await service.subscriptions.list({
maxResults: 10,
});
const subscriptions = result.data.subscriptions;
if (!subscriptions || subscriptions.length === 0) {
console.log('No subscriptions found.');
return;
}
// Print the customer ID, SKU ID, and plan name of each subscription.
console.log('Subscriptions:');
subscriptions.forEach(({customerId, skuId, plan}) => {
console.log(`${customerId} (${skuId}, ${plan?.planName})`);
});
}
await listSubscriptions();
// [END admin_sdk_reseller_quickstart]
================================================
FILE: adminSDK/reseller/package.json
================================================
{
"name": "google-reseller-nodejs-quickstart",
"version": "1.0.0",
"private": true,
"description": "A simple Node.js command-line application that makes requests to the Google Drive API.",
"license": "Apache-2.0",
"type": "module",
"scripts": {
"check": "tsc --noEmit"
},
"dependencies": {
"@google-cloud/local-auth": "catalog:",
"googleapis": "catalog:"
},
"devDependencies": {
"google-auth-library": "catalog:",
"typescript": "catalog:"
},
"engines": {
"node": ">=20"
}
}
================================================
FILE: adminSDK/reseller/tsconfig.json
================================================
{
"extends": "../../tsconfig.base.json",
"include": ["**/*.js"]
}
================================================
FILE: apps-script/execute/index.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START apps_script_api_execute]
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Calls an Apps Script function to list the folders in the user's root Drive folder.
*/
async function callAppsScript() {
// The ID of the Apps Script project to call.
const scriptId = '1xGOh6wCm7hlIVSVPKm0y_dL-YqetspS5DEVmMzaxd_6AAvI-_u8DSgBT';
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive',
});
// Create a new Apps Script API client.
const script = google.script({version: 'v1', auth});
const resp = await script.scripts.run({
auth,
requestBody: {
// The name of the function to call in the Apps Script project.
function: 'getFoldersUnderRoot',
},
scriptId,
});
if (resp.data.error?.details?.[0]) {
// The API executed, but the script returned an error.
// Extract the error details.
const error = resp.data.error.details[0];
console.log(`Script error message: ${error.errorMessage}`);
console.log('Script error stacktrace:');
if (error.scriptStackTraceElements) {
// Log the stack trace.
for (let i = 0; i < error.scriptStackTraceElements.length; i++) {
const trace = error.scriptStackTraceElements[i];
console.log('\t%s: %s', trace.function, trace.lineNumber);
}
}
} else {
// The script executed successfully.
// The structure of the response depends on the Apps Script function's return value.
const folderSet = resp.data.response ?? {};
if (Object.keys(folderSet).length === 0) {
console.log('No folders returned!');
} else {
console.log('Folders under your root folder:');
Object.keys(folderSet).forEach((id) => {
console.log('\t%s (%s)', folderSet[id], id);
});
}
}
}
// [END apps_script_api_execute]
callAppsScript();
================================================
FILE: apps-script/execute/package.json
================================================
{
"name": "apps-script-execute",
"version": "1.0.0",
"private": true,
"license": "Apache-2.0",
"type": "module",
"scripts": {
"check": "tsc --noEmit"
},
"devDependencies": {
"google-auth-library": "catalog:",
"typescript": "catalog:"
},
"engines": {
"node": ">=20"
},
"dependencies": {
"googleapis": "catalog:"
}
}
================================================
FILE: apps-script/execute/tsconfig.json
================================================
{
"extends": "../../tsconfig.base.json",
"include": ["**/*.js"]
}
================================================
FILE: apps-script/quickstart/index.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START apps_script_api_quickstart]
import path from 'node:path';
import process from 'node:process';
import {authenticate} from '@google-cloud/local-auth';
import {google} from 'googleapis';
const SCOPES = ['https://www.googleapis.com/auth/script.projects'];
const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
/**
* Creates a new script project, upload a file, and log the script's URL.
*/
async function callAppsScript() {
const auth = await authenticate({
scopes: SCOPES,
keyfilePath: CREDENTIALS_PATH,
});
const script = google.script({version: 'v1', auth});
const project = await script.projects.create({
requestBody: {
title: 'My Script',
},
});
if (!project.data.scriptId) {
throw new Error('Failed to create project');
}
await script.projects.updateContent({
scriptId: project.data.scriptId,
auth,
requestBody: {
files: [
{
name: 'hello',
type: 'SERVER_JS',
source: 'function helloWorld() {\n console.log("Hello, world!");\n}',
},
{
name: 'appsscript',
type: 'JSON',
source:
'{"timeZone":"America/New_York","exceptionLogging":' + '"CLOUD"}',
},
],
},
});
console.log(`https://script.google.com/d/${project.data.scriptId}/edit`);
}
await callAppsScript();
// [END apps_script_api_quickstart]
================================================
FILE: apps-script/quickstart/package.json
================================================
{
"name": "google-apps-script-nodejs-quickstart",
"version": "1.0.0",
"private": true,
"description": "A simple Node.js command-line application that makes requests to the Google Apps Script API.",
"license": "Apache-2.0",
"type": "module",
"scripts": {
"check": "tsc --noEmit"
},
"dependencies": {
"@google-cloud/local-auth": "catalog:",
"googleapis": "catalog:"
},
"devDependencies": {
"google-auth-library": "catalog:",
"typescript": "catalog:"
},
"engines": {
"node": ">=20"
}
}
================================================
FILE: apps-script/quickstart/tsconfig.json
================================================
{
"extends": "../../tsconfig.base.json",
"include": ["**/*.js"]
}
================================================
FILE: biome.json
================================================
{
"$schema": "https://biomejs.dev/schemas/2.2.4/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"bracketSpacing": false
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "single"
}
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
================================================
FILE: calendar/quickstart/index.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START calendar_quickstart]
import path from 'node:path';
import process from 'node:process';
import {authenticate} from '@google-cloud/local-auth';
import {google} from 'googleapis';
// The scope for reading calendar events.
const SCOPES = ['https://www.googleapis.com/auth/calendar.readonly'];
// The path to the credentials file.
const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
/**
* Lists the next 10 events on the user's primary calendar.
*/
async function listEvents() {
// Authenticate with Google and get an authorized client.
const auth = await authenticate({
scopes: SCOPES,
keyfilePath: CREDENTIALS_PATH,
});
// Create a new Calendar API client.
const calendar = google.calendar({version: 'v3', auth});
// Get the list of events.
const result = await calendar.events.list({
calendarId: 'primary',
timeMin: new Date().toISOString(),
maxResults: 10,
singleEvents: true,
orderBy: 'startTime',
});
const events = result.data.items;
if (!events || events.length === 0) {
console.log('No upcoming events found.');
return;
}
console.log('Upcoming 10 events:');
// Print the start time and summary of each event.
for (const event of events) {
const start = event.start?.dateTime ?? event.start?.date;
console.log(`${start} - ${event.summary}`);
}
}
await listEvents();
// [END calendar_quickstart]
================================================
FILE: calendar/quickstart/package.json
================================================
{
"name": "google-calendar-nodejs-quickstart",
"version": "1.0.0",
"private": true,
"description": "A simple Node.js command-line application that makes requests to the Google Calendar API.",
"license": "Apache-2.0",
"type": "module",
"scripts": {
"check": "tsc --noEmit"
},
"dependencies": {
"@google-cloud/local-auth": "catalog:",
"googleapis": "catalog:"
},
"devDependencies": {
"google-auth-library": "catalog:",
"typescript": "catalog:"
},
"engines": {
"node": ">=20"
}
}
================================================
FILE: calendar/quickstart/tsconfig.json
================================================
{
"extends": "../../tsconfig.base.json",
"include": ["**/*.js"]
}
================================================
FILE: chat/client-libraries/cloud/authentication-utils.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START chat_authentication_utils]
import {readFile} from 'node:fs/promises';
import http from 'node:http';
import url from 'node:url';
import {ChatServiceClient} from '@google-apps/chat';
import {OAuth2Client} from 'google-auth-library';
import open from 'open';
import destroyer from 'server-destroy';
// Application authentication
const SERVICE_ACCOUNT_FILE = './service_account.json';
const APP_AUTH_OAUTH_SCOPES = ['https://www.googleapis.com/auth/chat.bot'];
// User authentication
const CLIENT_SECRETS_FILE = './credentials.json';
const CLIENT_SECRETS = JSON.parse(
await readFile(new URL(CLIENT_SECRETS_FILE, import.meta.url), 'utf8'),
).web;
/**
* Create a new Chat service client with application credentials.
*
* @return {ChatServiceClient} The resulting client for the Chat service
*/
export function createClientWithAppCredentials() {
// For more information on app authentication, see
// https://developers.google.com/workspace/chat/authenticate-authorize-chat-app
return new ChatServiceClient({
keyFile: SERVICE_ACCOUNT_FILE,
scopes: APP_AUTH_OAUTH_SCOPES,
});
}
/**
* Create a new Chat service client with user credentials and scopes.
*
* @param {Array<string>} scopes Required scopes for the desired API requests
* @return {Promise<ChatServiceClient>} The resulting client for the Chat service
*/
export async function createClientWithUserCredentials(scopes) {
// For more information on user authentication, see
// https://developers.google.com/workspace/chat/authenticate-authorize-chat-user
return new ChatServiceClient({
authClient: await getAuthenticatedUserOAuth2Client(scopes),
scopes,
});
}
/**
* Create a new OAuth2 client and go through the OAuth2 flow.
*
* @param {Array<string>} scopes Required scopes for the desired API requests
* @return {Promise<OAuth2Client>} The resulting Google OAuth2 client
*/
function getAuthenticatedUserOAuth2Client(scopes) {
return new Promise((resolve, reject) => {
// Create a client based on client secrets
const oAuth2Client = new OAuth2Client(
CLIENT_SECRETS.client_id,
CLIENT_SECRETS.client_secret,
CLIENT_SECRETS.redirect_uris[0],
);
// Generate the URL to use for consent
const authorizeUrl = oAuth2Client.generateAuthUrl({
access_type: 'offline',
scope: scopes,
});
// Creates and starts an HTTP server to accept the OAuth2 callback.
const server = http
.createServer(async (request, response) => {
try {
if (request.url.indexOf('/oauth2callback') > -1) {
// Acquire the code and close the server.
const queryString = new url.URL(
request.url,
'http://localhost:3000',
).searchParams;
const code = queryString.get('code');
response.end('Done!');
server.destroy();
// Acquire the tokens
const r = await oAuth2Client.getToken(code);
// Update credentials of the OAuth2 client.
oAuth2Client.setCredentials(r.tokens);
resolve(oAuth2Client);
}
} catch (e) {
reject(e);
}
})
.listen(3000, () => {
// Opens the default browser to start the OAuth2 flow.
open(authorizeUrl, {wait: false}).then((cp) => cp.unref());
});
destroyer(server);
});
}
// [END chat_authentication_utils]
================================================
FILE: chat/client-libraries/cloud/create-custom-emoji-user-cred.js
================================================
/**
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START chat_create_custom_emoji_user_cred]
import fs from 'node:fs';
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.customemojis',
];
// This sample shows how to create custom emoji with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// TODO(developer) Replace FILENAME here.
const filename = 'FILENAME';
// Read custom emoji file content into a base64 encoded string.
const fileContent = fs.readFileSync(filename, {encoding: 'base64'});
// Initialize request argument(s)
const request = {
custom_emoji: {
// TODO(developer): Replace EMOJI_NAME here.
emoji_name: 'EMOJI_NAME',
payload: {
file_content: fileContent,
filename,
},
},
};
// Make the request
const response = await chatClient.createCustomEmoji(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_create_custom_emoji_user_cred]
================================================
FILE: chat/client-libraries/cloud/create-membership-user-cred-for-app.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_create_membership_user_cred_for_app]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.memberships.app',
];
// This sample shows how to create an app membership.
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME here.
parent: 'spaces/SPACE_NAME',
membership: {
member: {
// Member name for app membership, do not change this
name: 'users/app',
// User type for the membership
type: 'BOT',
},
},
};
// Make the request
const response = await chatClient.createMembership(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_create_membership_user_cred_for_app]
================================================
FILE: chat/client-libraries/cloud/create-membership-user-cred-for-group.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_create_membership_user_cred_for_group]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.memberships',
];
// This sample shows how to create membership with user credential for a group
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME here.
parent: 'spaces/SPACE_NAME',
membership: {
groupMember: {
// Replace GROUP_NAME here
name: 'groups/GROUP_NAME',
},
},
};
// Make the request
const response = await chatClient.createMembership(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_create_membership_user_cred_for_group]
================================================
FILE: chat/client-libraries/cloud/create-membership-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_create_membership_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.memberships',
];
// This sample shows how to create membership with user credential for a human
// user
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME here.
parent: 'spaces/SPACE_NAME',
membership: {
member: {
// Replace USER_NAME here
name: 'users/USER_NAME',
// User type for the membership
type: 'HUMAN',
},
},
};
// Make the request
const response = await chatClient.createMembership(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_create_membership_user_cred]
================================================
FILE: chat/client-libraries/cloud/create-message-app-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_create_message_app_cred]
import {createClientWithAppCredentials} from './authentication-utils.js';
// This sample shows how to create message with app credential
async function main() {
// Create a client
const chatClient = createClientWithAppCredentials();
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME here.
parent: 'spaces/SPACE_NAME',
message: {
text:
'👋🌎 Hello world! I created this message by calling ' +
"the Chat API's `messages.create()` method.",
cardsV2: [
{
card: {
header: {
title: 'About this message',
imageUrl:
'https://fonts.gstatic.com/s/i/short-term/release/googlesymbols/info/default/24px.svg',
},
sections: [
{
header: 'Contents',
widgets: [
{
textParagraph: {
text:
'🔡 <b>Text</b> which can include ' +
'hyperlinks 🔗, emojis 😄🎉, and @mentions 🗣️.',
},
},
{
textParagraph: {
text:
'🖼️ A <b>card</b> to display visual elements' +
'and request information such as text 🔤, ' +
'dates and times 📅, and selections ☑️.',
},
},
{
textParagraph: {
text:
'👉🔘 An <b>accessory widget</b> which adds ' +
'a button to the bottom of a message.',
},
},
],
},
{
header: "What's next",
collapsible: true,
widgets: [
{
textParagraph: {
text: "❤️ <a href='https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages.reactions/create'>Add a reaction</a>.",
},
},
{
textParagraph: {
text:
"🔄 <a href='https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages/patch'>Update</a> " +
"or ❌ <a href='https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages/delete'>delete</a> " +
'the message.',
},
},
],
},
],
},
},
],
accessoryWidgets: [
{
buttonList: {
buttons: [
{
text: 'View documentation',
icon: {materialIcon: {name: 'link'}},
onClick: {
openLink: {
url: 'https://developers.google.com/workspace/chat/create-messages',
},
},
},
],
},
},
],
},
};
// Make the request
const response = await chatClient.createMessage(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_create_message_app_cred]
================================================
FILE: chat/client-libraries/cloud/create-message-user-cred-at-mention.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_create_message_user_cred_at_mention]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.messages.create',
];
// This sample shows how to create message with user credential with a user
// mention
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME here.
parent: 'spaces/SPACE_NAME',
message: {
// The user with USER_NAME will be mentioned if they are in the space
// Replace USER_NAME here
text: 'Hello <users/USER_NAME>!',
},
};
// Make the request
const response = await chatClient.createMessage(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_create_message_user_cred_at_mention]
================================================
FILE: chat/client-libraries/cloud/create-message-user-cred-message-id.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_create_message_user_cred_message_id]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.messages.create',
];
// This sample shows how to create a message with user credentials and a custom
// message id
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME here.
parent: 'spaces/SPACE_NAME',
// Message id lets chat apps get, update or delete a message without needing
// to store the system assigned ID in the message's resource name
messageId: 'client-MESSAGE-ID',
message: {text: 'Hello with user credential!'},
};
// Make the request
const response = await chatClient.createMessage(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_create_message_user_cred_message_id]
================================================
FILE: chat/client-libraries/cloud/create-message-user-cred-request-id.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_create_message_user_cred_request_id]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.messages.create',
];
// This sample shows how to create message with user credential with request id
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME here.
parent: 'spaces/SPACE_NAME',
// Specifying an existing request ID returns the message created with
// that ID instead of creating a new message
requestId: 'REQUEST_ID',
message: {text: 'Hello with user credential!'},
};
// Make the request
const response = await chatClient.createMessage(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_create_message_user_cred_request_id]
================================================
FILE: chat/client-libraries/cloud/create-message-user-cred-thread-key.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_create_message_user_cred_thread_key]
import {protos} from '@google-apps/chat';
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.messages.create',
];
// This sample shows how to create message with user credential with thread key
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME here.
parent: 'spaces/SPACE_NAME',
// Creates the message as a reply to the thread specified by thread_key
// If it fails, the message starts a new thread instead
messageReplyOption:
protos.google.chat.v1.CreateMessageRequest.MessageReplyOption
.REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD,
message: {
text: 'Hello with user credential!',
thread: {
// Thread key specifies a thread and is unique to the chat app
// that sets it
threadKey: 'THREAD_KEY',
},
},
};
// Make the request
const response = await chatClient.createMessage(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_create_message_user_cred_thread_key]
================================================
FILE: chat/client-libraries/cloud/create-message-user-cred-thread-name.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_create_message_user_cred_thread_name]
import {protos} from '@google-apps/chat';
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.messages.create',
];
// This sample shows how to create a message with user credentials in a named
// thread
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME here.
parent: 'spaces/SPACE_NAME',
// Creates the message as a reply to the thread specified by thread.name.
// If it fails, the message starts a new thread instead.
messageReplyOption:
protos.google.chat.v1.CreateMessageRequest.MessageReplyOption
.REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD,
message: {
text: 'Hello with user credential!',
thread: {
// Resource name of a thread that uniquely identify a thread
// Replace SPACE_NAME and THREAD_NAME here
name: 'spaces/SPACE_NAME/threads/THREAD_NAME',
},
},
};
// Make the request
const response = await chatClient.createMessage(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_create_message_user_cred_thread_name]
================================================
FILE: chat/client-libraries/cloud/create-message-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_create_message_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.messages.create',
];
// This sample shows how to create message with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME here.
parent: 'spaces/SPACE_NAME',
message: {
text:
'👋🌎 Hello world!' +
'Text messages can contain things like:\n\n' +
'* Hyperlinks 🔗\n' +
'* Emojis 😄🎉\n' +
'* Mentions of other Chat users `@` \n\n' +
'For details, see the ' +
'<https://developers.google.com/workspace/chat/format-messages' +
'|Chat API developer documentation>.',
},
};
// Make the request
const response = await chatClient.createMessage(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_create_message_user_cred]
================================================
FILE: chat/client-libraries/cloud/create-reaction-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_create_reaction_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.messages.reactions.create',
];
// This sample shows how to create reaction to a message with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME and MESSAGE_NAME here.
parent: 'spaces/SPACE_NAME/messages/MESSAGE_NAME',
reaction: {
// A standard emoji represented by a unicode string.
emoji: {unicode: '😀'},
},
};
// Make the request
const response = await chatClient.createReaction(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_create_reaction_user_cred]
================================================
FILE: chat/client-libraries/cloud/create-space-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_create_space_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.spaces.create',
];
// This sample shows how to create a named space with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
space: {
spaceType: 'SPACE',
// Replace DISPLAY_NAME here.
displayName: 'DISPLAY_NAME',
},
};
// Make the request
const response = await chatClient.createSpace(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_create_space_user_cred]
================================================
FILE: chat/client-libraries/cloud/delete-custom-emoji-user-cred.js
================================================
/**
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_delete_custom_emoji_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.customemojis',
];
// This sample shows how to delete a custom emoji with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// TODO(developer): Replace EMOJI_NAME here.
name: 'customEmojis/EMOJI_NAME',
};
// Make the request
const response = await chatClient.deleteCustomEmoji(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_delete_custom_emoji_user_cred]
================================================
FILE: chat/client-libraries/cloud/delete-membership-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_delete_membership_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.memberships',
];
// This sample shows how to delete a membership of type HUMAN with user
// credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME and MEMBER_NAME here
name: 'spaces/SPACE_NAME/members/MEMBER_NAME',
};
// Make the request
const response = await chatClient.deleteMembership(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_delete_membership_user_cred]
================================================
FILE: chat/client-libraries/cloud/delete-message-app-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_delete_message_app_cred]
import {createClientWithAppCredentials} from './authentication-utils.js';
// This sample shows how to delete a message with app credential
async function main() {
// Create a client
const chatClient = createClientWithAppCredentials();
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME and MESSAGE_NAME here
name: 'spaces/SPACE_NAME/messages/MESSAGE_NAME',
};
// Make the request
const response = await chatClient.deleteMessage(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_delete_message_app_cred]
================================================
FILE: chat/client-libraries/cloud/delete-message-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_delete_message_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.messages',
];
// This sample shows how to delete a message with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME and MESSAGE_NAME here
name: 'spaces/SPACE_NAME/messages/MESSAGE_NAME',
};
// Make the request
const response = await chatClient.deleteMessage(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_delete_message_user_cred]
================================================
FILE: chat/client-libraries/cloud/delete-reaction-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_delete_reaction_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.messages.reactions',
];
// This sample shows how to delete a reaction to a message with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME, MESSAGE_NAME, and REACTION_NAME here
name: 'spaces/SPACE_NAME/messages/MESSAGE_NAME/reactions/REACTION_NAME',
};
// Make the request
const response = await chatClient.deleteReaction(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_delete_reaction_user_cred]
================================================
FILE: chat/client-libraries/cloud/delete-space-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_delete_space_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = ['https://www.googleapis.com/auth/chat.delete'];
// This sample shows how to delete a space with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME here
name: 'spaces/SPACE_NAME',
};
// Make the request
const response = await chatClient.deleteSpace(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_delete_space_user_cred]
================================================
FILE: chat/client-libraries/cloud/find-dm-space-app-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_find_dm_space_app_cred]
import {createClientWithAppCredentials} from './authentication-utils.js';
// This sample shows how to find a Direct Message space with app credential
async function main() {
// Create a client
const chatClient = createClientWithAppCredentials();
// Initialize request argument(s)
const request = {
// Replace USER_NAME here
name: 'users/USER_NAME',
};
// Make the request
const response = await chatClient.findDirectMessage(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_find_dm_space_app_cred]
================================================
FILE: chat/client-libraries/cloud/find-dm-space-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_find_dm_space_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.spaces.readonly',
];
// This sample shows how to find a Direct Message space with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace USER_NAME here
name: 'users/USER_NAME',
};
// Make the request
const response = await chatClient.findDirectMessage(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_find_dm_space_user_cred]
================================================
FILE: chat/client-libraries/cloud/get-attachment-app-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_get_attachment_app_cred]
import {createClientWithAppCredentials} from './authentication-utils.js';
// This sample shows how to get attachment metadata with app
// credential
async function main() {
// Create a client
const chatClient = createClientWithAppCredentials();
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME, MESSAGE_NAME, and ATTACHMENT_NAME here
name: 'spaces/SPACE_NAME/messages/MESSAGE_NAME/attachments/ATTACHMENT_NAME',
};
// Make the request
const response = await chatClient.getAttachment(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_get_attachment_app_cred]
================================================
FILE: chat/client-libraries/cloud/get-custom-emoji-user-cred.js
================================================
/**
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_get_custom_emoji_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.customemojis',
];
// This sample shows how to get custom emoji with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// TODO(developer): Replace EMOJI_NAME here
name: 'customEmojis/EMOJI_NAME',
};
// Make the request
const response = await chatClient.getCustomEmoji(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_get_custom_emoji_user_cred]
================================================
FILE: chat/client-libraries/cloud/get-membership-app-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_get_membership_app_cred]
import {createClientWithAppCredentials} from './authentication-utils.js';
// This sample shows how to get membership with app credential
async function main() {
// Create a client
const chatClient = createClientWithAppCredentials();
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME and MEMBER_NAME here
name: 'spaces/SPACE_NAME/members/MEMBER_NAME',
};
// Make the request
const response = await chatClient.getMembership(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_get_membership_app_cred]
================================================
FILE: chat/client-libraries/cloud/get-membership-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_get_membership_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.memberships.readonly',
];
// This sample shows how to get membership with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME and MEMBER_NAME here
name: 'spaces/SPACE_NAME/members/MEMBER_NAME',
};
// Make the request
const response = await chatClient.getMembership(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_get_membership_user_cred]
================================================
FILE: chat/client-libraries/cloud/get-message-app-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_get_message_app_cred]
import {createClientWithAppCredentials} from './authentication-utils.js';
// This sample shows how to get message with app credential
async function main() {
// Create a client
const chatClient = createClientWithAppCredentials();
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME and MESSAGE_NAME here
name: 'spaces/SPACE_NAME/messages/MESSAGE_NAME',
};
// Make the request
const response = await chatClient.getMessage(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_get_message_app_cred]
================================================
FILE: chat/client-libraries/cloud/get-message-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_get_message_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.messages.readonly',
];
// This sample shows how to get message with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME and MESSAGE_NAME here
name: 'spaces/SPACE_NAME/messages/MESSAGE_NAME',
};
// Make the request
const response = await chatClient.getMessage(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_get_message_user_cred]
================================================
FILE: chat/client-libraries/cloud/get-space-app-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_get_space_app_cred]
import {createClientWithAppCredentials} from './authentication-utils.js';
// This sample shows how to get space with app credential
async function main() {
// Create a client
const chatClient = createClientWithAppCredentials();
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME here
name: 'spaces/SPACE_NAME',
};
// Make the request
const response = await chatClient.getSpace(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_get_space_app_cred]
================================================
FILE: chat/client-libraries/cloud/get-space-event-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START chat_get_space_event_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
// Replace SCOPE_NAME here with an authorization scope based on the event type
const USER_AUTH_OAUTH_SCOPES = ['SCOPE_NAME'];
// This sample shows how to get space event with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME and SPACE_EVENT_NAME here
name: 'spaces/SPACE_NAME/spaceEvents/SPACE_EVENT_NAME',
};
// Make the request
const response = await chatClient.getSpaceEvent(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_get_space_event_user_cred]
================================================
FILE: chat/client-libraries/cloud/get-space-notification-setting-user-cred.js
================================================
/**
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_get_space_notification_setting_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.users.spacesettings',
];
// This sample shows how to get the space notification setting for the calling
// user
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s), replace the SPACE_NAME with an actual space
// name.
const request = {
name: 'users/me/spaces/SPACE_NAME/spaceNotificationSetting',
};
// Make the request
const response = await chatClient.getSpaceNotificationSetting(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_get_space_notification_setting_user_cred]
================================================
FILE: chat/client-libraries/cloud/get-space-read-state-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_get_space_read_state_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.users.readstate.readonly',
];
// This sample shows how to get the space read state for the calling user
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME here
name: 'users/me/spaces/SPACE_NAME/spaceReadState',
};
// Make the request
const response = await chatClient.getSpaceReadState(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_get_space_read_state_user_cred]
================================================
FILE: chat/client-libraries/cloud/get-space-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_get_space_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.spaces.readonly',
];
// This sample shows how to get space with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME here
name: 'spaces/SPACE_NAME',
};
// Make the request
const response = await chatClient.getSpace(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_get_space_user_cred]
================================================
FILE: chat/client-libraries/cloud/get-thread-read-state-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_get_thread_read_state_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.users.readstate.readonly',
];
// This sample shows how to get the thread read state for a space and calling
// user
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME and THREAD_NAME here
name: 'users/me/spaces/SPACE_NAME/threads/THREAD_NAME/threadReadState',
};
// Make the request
const response = await chatClient.getThreadReadState(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_get_thread_read_state_user_cred]
================================================
FILE: chat/client-libraries/cloud/list-custom-emojis-user-cred.js
================================================
/**
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_list_custom_emojis_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.customemojis',
];
// This sample shows how to get custom emoji with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Optional. Replace FILTER here
filter: 'FILTER',
};
// Make the request
const pageResult = await chatClient.listCustomEmojisAsync(request);
// Handle the response. Iterating over pageResult will yield results and
// resolve additional pages automatically.
for await (const response of pageResult) {
console.log(response);
}
}
await main();
// [END chat_list_custom_emojis_user_cred]
================================================
FILE: chat/client-libraries/cloud/list-memberships-app-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_list_memberships_app_cred]
import {createClientWithAppCredentials} from './authentication-utils.js';
// This sample shows how to list memberships with app credential
async function main() {
// Create a client
const chatClient = createClientWithAppCredentials();
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME here
parent: 'spaces/SPACE_NAME',
// Filter membership by type (HUMAN or BOT) or role (ROLE_MEMBER or
// ROLE_MANAGER)
filter: 'member.type = "HUMAN"',
};
// Make the request
const pageResult = chatClient.listMembershipsAsync(request);
// Handle the response. Iterating over pageResult will yield results and
// resolve additional pages automatically.
for await (const response of pageResult) {
console.log(response);
}
}
await main();
// [END chat_list_memberships_app_cred]
================================================
FILE: chat/client-libraries/cloud/list-memberships-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_list_memberships_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.memberships.readonly',
];
// This sample shows how to list memberships with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME here
parent: 'spaces/SPACE_NAME',
// Filter membership by type (HUMAN or BOT) or role (ROLE_MEMBER or
// ROLE_MANAGER)
filter: 'member.type = "HUMAN"',
};
// Make the request
const pageResult = chatClient.listMembershipsAsync(request);
// Handle the response. Iterating over pageResult will yield results and
// resolve additional pages automatically.
for await (const response of pageResult) {
console.log(response);
}
}
await main();
// [END chat_list_memberships_user_cred]
================================================
FILE: chat/client-libraries/cloud/list-messages-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_list_messages_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.messages.readonly',
];
// This sample shows how to list messages with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME here
parent: 'spaces/SPACE_NAME',
};
// Make the request
const pageResult = chatClient.listMessagesAsync(request);
// Handle the response. Iterating over pageResult will yield results
// and resolve additional pages automatically.
for await (const response of pageResult) {
console.log(response);
}
}
await main();
// [END chat_list_messages_user_cred]
================================================
FILE: chat/client-libraries/cloud/list-reactions-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_list_reactions_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.messages.reactions.readonly',
];
// This sample shows how to list reactions to a message with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME and MESSAGE_NAME here.
parent: 'spaces/SPACE_NAME/messages/MESSAGE_NAME',
};
// Make the request
const pageResult = chatClient.listReactionsAsync(request);
// Handle the response. Iterating over pageResult will yield results
// and resolve additional pages automatically.
for await (const response of pageResult) {
console.log(response);
}
}
await main();
// [END chat_list_reactions_user_cred]
================================================
FILE: chat/client-libraries/cloud/list-space-events-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_list_space_events_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
// Authorization scopes based on the event types
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.memberships.readonly',
'https://www.googleapis.com/auth/chat.messages.readonly',
];
// This sample shows how to list space events with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Replace SPACE_NAME here
parent: 'spaces/SPACE_NAME',
// A required filter. Filters events about new memberships and messages.
filter:
'eventTypes:"google.workspace.chat.membership.v1.created" OR eventTypes:"google.workspace.chat.message.v1.created"',
};
// Make the request
const pageResult = chatClient.listSpaceEventsAsync(request);
// Handle the response. Iterating over pageResult will yield results and
// resolve additional pages automatically.
for await (const response of pageResult) {
console.log(response);
}
}
await main();
// [END chat_list_space_events_user_cred]
================================================
FILE: chat/client-libraries/cloud/list-spaces-app-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_list_spaces_app_cred]
import {createClientWithAppCredentials} from './authentication-utils.js';
// This sample shows how to list spaces with app credential
async function main() {
// Create a client
const chatClient = createClientWithAppCredentials();
// Initialize request argument(s)
const request = {
// Filter spaces by space type (SPACE or GROUP_CHAT or DIRECT_MESSAGE)
filter: 'space_type = "SPACE"',
};
// Make the request
const pageResult = chatClient.listSpacesAsync(request);
// Handle the response. Iterating over pageResult will yield results
// and resolve additional pages automatically.
for await (const response of pageResult) {
console.log(response);
}
}
await main();
// [END chat_list_spaces_app_cred]
================================================
FILE: chat/client-libraries/cloud/list-spaces-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_list_spaces_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.spaces.readonly',
];
// This sample shows how to list spaces with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
// Filter spaces by space type (SPACE or GROUP_CHAT or DIRECT_MESSAGE)
filter: 'space_type = "SPACE"',
};
// Make the request
const pageResult = chatClient.listSpacesAsync(request);
// Handle the response. Iterating over pageResult will yield results
// and resolve additional pages automatically.
for await (const response of pageResult) {
console.log(response);
}
}
await main();
// [END chat_list_spaces_user_cred]
================================================
FILE: chat/client-libraries/cloud/package.json
================================================
{
"name": "google-chat-cloud-client-library-samples",
"version": "0.0.1",
"description": "Samples that use the Cloud client library to call the Google Chat API.",
"license": "Apache-2.0",
"type": "module",
"scripts": {
"create-custom-emoji-user-cred.js": "node ./create-custom-emoji-user-cred.js",
"create-membership-user-cred-for-app.js": "node ./create-membership-user-cred-for-app.js",
"create-membership-user-cred-for-group.js": "node ./create-membership-user-cred-for-group.js",
"create-membership-user-cred.js": "node ./create-membership-user-cred.js",
"create-message-app-cred.js": "node ./create-message-app-cred.js",
"create-message-user-cred-at-mention.js": "node ./create-message-user-cred-at-mention.js",
"create-message-user-cred-message-id.js": "node ./create-message-user-cred-message-id.js",
"create-message-user-cred-request-id.js": "node ./create-message-user-cred-request-id.js",
"create-message-user-cred-thread-key.js": "node ./create-message-user-cred-thread-key.js",
"create-message-user-cred-thread-name.js": "node ./create-message-user-cred-thread-name.js",
"create-message-user-cred.js": "node ./create-message-user-cred.js",
"create-reaction-user-cred.js": "node ./create-reaction-user-cred.js",
"create-space-user-cred.js": "node ./create-space-user-cred.js",
"delete-custom-emoji-user-cred.js": "node ./delete-custom-emoji-user-cred.js",
"delete-membership-user-cred.js": "node ./delete-membership-user-cred.js",
"delete-message-app-cred.js": "node ./delete-message-app-cred.js",
"delete-message-user-cred.js": "node ./delete-message-user-cred.js",
"delete-reaction-user-cred.js": "node ./delete-reaction-user-cred.js",
"delete-space-user-cred.js": "node ./delete-space-user-cred.js",
"find-dm-space-app-cred.js": "node ./find-dm-space-app-cred.js",
"find-dm-space-user-cred.js": "node ./find-dm-space-user-cred.js",
"get-attachment-app-cred.js": "node ./get-attachment-app-cred.js",
"get-custom-emoji-user-cred.js": "node ./get-custom-emoji-user-cred.js",
"get-membership-app-cred.js": "node ./get-membership-app-cred.js",
"get-membership-user-cred.js": "node ./get-membership-user-cred.js",
"get-message-app-cred.js": "node ./get-message-app-cred.js",
"get-message-user-cred.js": "node ./get-message-user-cred.js",
"get-space-app-cred.js": "node ./get-space-app-cred.js",
"get-space-event-user-cred.js": "node ./get-space-event-user-cred.js",
"get-space-notification-setting-user-cred.js": "node ./get-space-notification-setting-user-cred.js",
"get-space-read-state-user-cred.js": "node ./get-space-read-state-user-cred.js",
"get-space-user-cred.js": "node ./get-space-user-cred.js",
"get-thread-read-state-user-cred.js": "node ./get-thread-read-state-user-cred.js",
"list-custom-emojis-user-cred.js": "node ./list-custom-emojis-user-cred.js",
"list-memberships-app-cred.js": "node ./list-memberships-app-cred.js",
"list-memberships-user-cred.js": "node ./list-memberships-user-cred.js",
"list-messages-user-cred.js": "node ./list-messages-user-cred.js",
"list-reactions-user-cred.js": "node ./list-reactions-user-cred.js",
"list-space-events-user-cred.js": "node ./list-space-events-user-cred.js",
"list-spaces-app-cred.js": "node ./list-spaces-app-cred.js",
"list-spaces-user-cred.js": "node ./list-spaces-user-cred.js",
"set-up-space-user-cred.js": "node ./set-up-space-user-cred.js",
"update-membership-user-cred.js": "node ./update-membership-user-cred.js",
"update-message-app-cred.js": "node ./update-message-app-cred.js",
"update-message-user-cred.js": "node ./update-message-user-cred.js",
"update-space-notification-setting-user-cred.js": "node ./update-space-notification-setting-user-cred.js",
"update-space-read-state-user-cred.js": "node ./update-space-read-state-user-cred.js",
"update-space-user-cred.js": "node ./update-space-user-cred.js"
},
"dependencies": {
"@google-apps/chat": "catalog:",
"@grpc/grpc-js": "catalog:",
"open": "catalog:",
"server-destroy": "catalog:"
},
"devDependencies": {
"google-auth-library": "catalog:",
"typescript": "catalog:"
},
"engines": {
"node": ">=20"
}
}
================================================
FILE: chat/client-libraries/cloud/set-up-space-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_set_up_space_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.spaces.create',
];
// This sample shows how to set up a named space with one initial member
// with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
space: {
spaceType: 'SPACE',
// Replace DISPLAY_NAME here.
displayName: 'DISPLAY_NAME',
},
memberships: [
{
member: {
// Replace USER_NAME here.
name: 'users/USER_NAME',
type: 'HUMAN',
},
},
],
};
// Make the request
const response = await chatClient.setUpSpace(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_set_up_space_user_cred]
================================================
FILE: chat/client-libraries/cloud/tsconfig.json
================================================
{
"extends": "../../../../tsconfig.base.json",
"include": ["**/*.js"]
}
================================================
FILE: chat/client-libraries/cloud/update-membership-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_update_membership_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.memberships',
];
// This sample shows how to update a membership with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
membership: {
// Replace SPACE_NAME and MEMBER_NAME here
name: 'spaces/SPACE_NAME/members/MEMBER_NAME',
// Replace ROLE_NAME here with ROLE_MEMBER or ROLE_MANAGER
role: 'ROLE_NAME',
},
updateMask: {
// The field paths to update.
paths: ['role'],
},
};
// Make the request
const response = await chatClient.updateMembership(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_update_membership_user_cred]
================================================
FILE: chat/client-libraries/cloud/update-message-app-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_update_message_app_cred]
import {createClientWithAppCredentials} from './authentication-utils.js';
// This sample shows how to update a message with app credential
async function main() {
// Create a client
const chatClient = createClientWithAppCredentials();
// Initialize request argument(s)
const request = {
message: {
// Replace SPACE_NAME and MESSAGE_NAME here
name: 'spaces/SPACE_NAME/messages/MESSAGE_NAME',
text: 'Text updated with app credential!',
cardsV2: [
{
card: {
header: {
title: 'Card updated with app credential!',
imageUrl:
'https://fonts.gstatic.com/s/i/short-term/release/googlesymbols/info/default/24px.svg',
},
},
},
],
},
// The field paths to update. Separate multiple values with commas or use `*`
// to update all field paths.
updateMask: {
// The field paths to update.
paths: ['text', 'cards_v2'],
},
};
// Make the request
const response = await chatClient.updateMessage(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_update_message_app_cred]
================================================
FILE: chat/client-libraries/cloud/update-message-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_update_message_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.messages',
];
// This sample shows how to update a message with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
message: {
// Replace SPACE_NAME and MESSAGE_NAME here
name: 'spaces/SPACE_NAME/messages/MESSAGE_NAME',
text: 'Updated with user credential!',
},
// The field paths to update. Separate multiple values with commas or use `*`
// to update all field paths.
updateMask: {
// The field paths to update.
paths: ['text'],
},
};
// Make the request
const response = await chatClient.updateMessage(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_update_message_user_cred]
================================================
FILE: chat/client-libraries/cloud/update-space-notification-setting-user-cred.js
================================================
/**
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_update_space_notification_setting_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.users.spacesettings',
];
// This sample shows how to update the space notification setting for the
// calling user
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s), replace the SPACE_NAME with an actual space
// name.
const request = {
spaceNotificationSetting: {
name: 'users/me/spaces/SPACE_NAME/spaceNotificationSetting',
notificationSetting: 'ALL',
muteSetting: 'UNMUTED',
},
updateMask: {paths: ['notification_setting', 'mute_setting']},
};
// Make the request
const response = await chatClient.updateSpaceNotificationSetting(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_update_space_notification_setting_user_cred]
================================================
FILE: chat/client-libraries/cloud/update-space-read-state-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_update_space_read_state_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = [
'https://www.googleapis.com/auth/chat.users.readstate',
];
// This sample shows how to update a space read state for the calling user
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const timestamp = new Date('2000-01-01').getTime();
const request = {
spaceReadState: {
// Replace SPACE_NAME here
name: 'users/me/spaces/SPACE_NAME/spaceReadState',
lastReadTime: {
seconds: Math.floor(timestamp / 1000),
nanos: (timestamp % 1000) * 1000000,
},
},
updateMask: {
// The field paths to update.
paths: ['last_read_time'],
},
};
// Make the request
const response = await chatClient.updateSpaceReadState(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_update_space_read_state_user_cred]
================================================
FILE: chat/client-libraries/cloud/update-space-user-cred.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// It may require modifications to work in your environment.
// [START chat_update_space_user_cred]
import {createClientWithUserCredentials} from './authentication-utils.js';
const USER_AUTH_OAUTH_SCOPES = ['https://www.googleapis.com/auth/chat.spaces'];
// This sample shows how to update a space with user credential
async function main() {
// Create a client
const chatClient = await createClientWithUserCredentials(
USER_AUTH_OAUTH_SCOPES,
);
// Initialize request argument(s)
const request = {
space: {
// Replace SPACE_NAME here
name: 'spaces/SPACE_NAME',
displayName: 'New space display name',
},
// The field paths to update. Separate multiple values with commas or use `*`
// to update all field paths.
updateMask: {
// The field paths to update.
paths: ['display_name'],
},
};
// Make the request
const response = await chatClient.updateSpace(request);
// Handle the response
console.log(response);
}
await main();
// [END chat_update_space_user_cred]
================================================
FILE: chat/quickstart/index.js
================================================
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START chat_quickstart]
import path from 'node:path';
import process from 'node:process';
import {ChatServiceClient} from '@google-apps/chat';
import {authenticate} from '@google-cloud/local-auth';
// The scope for reading Chat spaces.
const SCOPES = ['https://www.googleapis.com/auth/chat.spaces.readonly'];
// The path to the credentials file.
const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
/**
* Lists the spaces that the user is a member of.
*/
async function listSpaces() {
// Authenticate with Google and get an authorized client.
const authClient = await authenticate({
scopes: SCOPES,
keyfilePath: CREDENTIALS_PATH,
});
// Create a new Chat API client.
const chatClient = new ChatServiceClient({
authClient,
scopes: SCOPES,
});
// The request to list spaces.
const request = {
// Filter spaces by type. In this case, we are only interested in "SPACE" type.
filter: 'space_type = "SPACE"',
};
// Make the API request.
const pageResult = chatClient.listSpacesAsync(request);
// Process the response.
// The `pageResult` is an async iterable that will yield each space.
for await (const response of pageResult) {
console.log(response);
}
}
await listSpaces();
// [END chat_quickstart]
================================================
FILE: chat/quickstart/package.json
================================================
{
"name": "google-chat-nodejs-quickstart",
"version": "1.0.0",
"private": true,
"description": "A simple Node.js command-line application that makes requests to the Google Chat API.",
"license": "Apache-2.0",
"type": "module",
"scripts": {
"check": "tsc --noEmit"
},
"dependencies": {
"@google-apps/chat": "catalog:",
"@google-cloud/local-auth": "catalog:"
},
"devDependencies": {
"google-auth-library": "catalog:",
"typescript": "catalog:"
},
"engines": {
"node": ">=20"
}
}
================================================
FILE: chat/quickstart/tsconfig.json
================================================
{
"extends": "../../tsconfig.base.json",
"include": ["**/*.js"]
}
================================================
FILE: classroom/quickstart/index.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START classroom_quickstart]
import path from 'node:path';
import process from 'node:process';
import {authenticate} from '@google-cloud/local-auth';
import {google} from 'googleapis';
// The scope for reading Classroom courses.
const SCOPES = ['https://www.googleapis.com/auth/classroom.courses.readonly'];
// The path to the credentials file.
const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
/**
* Lists the first 10 courses the user has access to.
*/
async function listCourses() {
// Authenticate with Google and get an authorized client.
const auth = await authenticate({
scopes: SCOPES,
keyfilePath: CREDENTIALS_PATH,
});
// Create a new Classroom API client.
const classroom = google.classroom({version: 'v1', auth});
// Get the list of courses.
const result = await classroom.courses.list({
pageSize: 10,
});
const courses = result.data.courses;
if (!courses || courses.length === 0) {
console.log('No courses found.');
return;
}
console.log('Courses:');
// Print the name and ID of each course.
courses.forEach((course) => {
console.log(`${course.name} (${course.id})`);
});
}
await listCourses();
// [END classroom_quickstart]
================================================
FILE: classroom/quickstart/package.json
================================================
{
"name": "google-classroom-nodejs-quickstart",
"version": "1.0.0",
"private": true,
"description": "A simple Node.js command-line application that makes requests to the Google Classroom API.",
"license": "Apache-2.0",
"type": "module",
"scripts": {
"check": "tsc --noEmit"
},
"dependencies": {
"@google-cloud/local-auth": "catalog:",
"googleapis": "catalog:"
},
"devDependencies": {
"google-auth-library": "catalog:",
"typescript": "catalog:"
},
"engines": {
"node": ">=20"
}
}
================================================
FILE: classroom/quickstart/tsconfig.json
================================================
{
"extends": "../../tsconfig.base.json",
"include": ["**/*.js"]
}
================================================
FILE: docs/quickstart/index.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START docs_quickstart]
import path from 'node:path';
import process from 'node:process';
import {authenticate} from '@google-cloud/local-auth';
import {google} from 'googleapis';
// The scope for reading Google Docs.
const SCOPES = ['https://www.googleapis.com/auth/documents.readonly'];
// The path to the credentials file.
const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
/**
* Prints the title of a sample doc:
* https://docs.google.com/document/d/195j9eDD3ccgjQRttHhJPymLJUCOUjs-jmwTrekvdjFE/edit
*/
async function printDocTitle() {
// Authenticate with Google and get an authorized client.
const auth = await authenticate({
scopes: SCOPES,
keyfilePath: CREDENTIALS_PATH,
});
// Create a new Docs API client.
const docs = google.docs({version: 'v1', auth});
// Get the document.
const result = await docs.documents.get({
documentId: '195j9eDD3ccgjQRttHhJPymLJUCOUjs-jmwTrekvdjFE',
});
// Print the title of the document.
console.log(`The title of the document is: ${result.data.title}`);
}
await printDocTitle();
// [END docs_quickstart]
================================================
FILE: docs/quickstart/package.json
================================================
{
"name": "docs-nodejs-quickstart",
"version": "1.0.0",
"private": true,
"description": "A simple Node.js command-line application that makes requests to the Docs API.",
"license": "Apache-2.0",
"type": "module",
"scripts": {
"check": "tsc --noEmit"
},
"dependencies": {
"@google-cloud/local-auth": "catalog:",
"googleapis": "catalog:"
},
"devDependencies": {
"google-auth-library": "catalog:",
"typescript": "catalog:"
},
"engines": {
"node": ">=20"
}
}
================================================
FILE: docs/quickstart/tsconfig.json
================================================
{
"extends": "../../tsconfig.base.json",
"include": ["**/*.js"]
}
================================================
FILE: drive/activity-v2/index.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_activity_v2_quickstart]
import path from 'node:path';
import process from 'node:process';
import {authenticate} from '@google-cloud/local-auth';
import {google} from 'googleapis';
// The scope for reading Drive activity.
const SCOPES = ['https://www.googleapis.com/auth/drive.activity.readonly'];
// The path to the credentials file.
const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
/**
* Lists the recent activity in your Google Drive.
*/
async function listDriveActivity() {
// Authenticate with Google and get an authorized client.
const auth = await authenticate({
scopes: SCOPES,
keyfilePath: CREDENTIALS_PATH,
});
// Create a new Drive Activity API client.
const service = google.driveactivity({version: 'v2', auth});
// The parameters for the activity query.
const params = {
pageSize: 10,
};
// Query for recent activity.
const result = await service.activity.query({requestBody: params});
const activities = result.data.activities;
if (!activities || activities.length === 0) {
console.log('No activity.');
return;
}
console.log('Recent activity:');
// Print the recent activity.
console.log(JSON.stringify(activities, null, 2));
}
await listDriveActivity();
// [END drive_activity_v2_quickstart]
================================================
FILE: drive/activity-v2/package.json
================================================
{
"name": "google-drive-activity-v2-nodejs-quickstart",
"version": "1.0.0",
"private": true,
"description": "A simple Node.js command-line application that makes requests to the Google Drive Activity v2 API.",
"license": "Apache-2.0",
"type": "module",
"scripts": {
"check": "tsc --noEmit"
},
"dependencies": {
"@google-cloud/local-auth": "catalog:",
"googleapis": "catalog:"
},
"devDependencies": {
"google-auth-library": "catalog:",
"typescript": "catalog:"
},
"engines": {
"node": ">=20"
}
}
================================================
FILE: drive/activity-v2/tsconfig.json
================================================
{
"extends": "../../tsconfig.base.json",
"include": ["**/*.js"]
}
================================================
FILE: drive/quickstart/index.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_quickstart]
import path from 'node:path';
import process from 'node:process';
import {authenticate} from '@google-cloud/local-auth';
import {google} from 'googleapis';
// The scope for reading file metadata.
const SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly'];
// The path to the credentials file.
const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
/**
* Lists the names and IDs of up to 10 files.
*/
async function listFiles() {
// Authenticate with Google and get an authorized client.
const auth = await authenticate({
scopes: SCOPES,
keyfilePath: CREDENTIALS_PATH,
});
// Create a new Drive API client.
const drive = google.drive({version: 'v3', auth});
// Get the list of files.
const result = await drive.files.list({
pageSize: 10,
fields: 'nextPageToken, files(id, name)',
});
const files = result.data.files;
if (!files || files.length === 0) {
console.log('No files found.');
return;
}
console.log('Files:');
// Print the name and ID of each file.
files.forEach((file) => {
console.log(`${file.name} (${file.id})`);
});
}
await listFiles();
// [END drive_quickstart]
================================================
FILE: drive/quickstart/package.json
================================================
{
"name": "google-drive-nodejs-quickstart",
"version": "1.0.0",
"private": true,
"description": "A simple Node.js command-line application that makes requests to the Google Drive API.",
"license": "Apache-2.0",
"type": "module",
"scripts": {
"check": "tsc --noEmit"
},
"dependencies": {
"@google-cloud/local-auth": "catalog:",
"googleapis": "catalog:"
},
"devDependencies": {
"google-auth-library": "catalog:",
"typescript": "catalog:"
},
"engines": {
"node": ">=20"
}
}
================================================
FILE: drive/quickstart/tsconfig.json
================================================
{
"extends": "../../tsconfig.base.json",
"include": ["**/*.js"]
}
================================================
FILE: drive/snippets/drive_v2/appdata_snippets/fetch_appdata_folder.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_fetch_appdata_folder]
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Fetches the ID of the application data folder.
* @return {Promise<string>} The ID of the application data folder.
*/
async function fetchAppdataFolder() {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive.appdata',
});
// Create a new Drive API client.
const service = google.drive({version: 'v2', auth});
// Get the application data folder.
const file = await service.files.get({
fileId: 'appDataFolder',
fields: 'id',
});
// Print the folder ID.
console.log('File Id:', file.data.id);
if (!file.data.id) {
throw new Error('File ID not found.');
}
return file.data.id;
}
// [END drive_fetch_appdata_folder]
export {fetchAppdataFolder};
================================================
FILE: drive/snippets/drive_v2/appdata_snippets/list_appdata.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_list_appdata]
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Lists all files in the application data folder.
* @return {Promise<object[]>} A list of files.
*/
async function listAppdata() {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive.appdata',
});
// Create a new Drive API client.
const service = google.drive({version: 'v2', auth});
// List the files in the application data folder.
const result = await service.files.list({
spaces: 'appDataFolder',
fields: 'nextPageToken, items(id, title)',
maxResults: 100,
});
// Print the title and ID of each file.
(result.data.items ?? []).forEach((file) => {
console.log('Found file:', file.title, file.id);
});
return result.data.items ?? [];
}
// [END drive_list_appdata]
export {listAppdata};
================================================
FILE: drive/snippets/drive_v2/appdata_snippets/package.json
================================================
{
"name": "drive-snippets-drive-v2-appdata-snippets",
"version": "1.0.0",
"private": true,
"license": "Apache-2.0",
"type": "module",
"scripts": {
"check": "tsc --noEmit"
},
"devDependencies": {
"google-auth-library": "catalog:",
"typescript": "catalog:"
},
"engines": {
"node": ">=20"
},
"dependencies": {
"googleapis": "catalog:"
}
}
================================================
FILE: drive/snippets/drive_v2/appdata_snippets/tsconfig.json
================================================
{
"extends": "../../../../tsconfig.base.json",
"include": ["**/*.js"]
}
================================================
FILE: drive/snippets/drive_v2/appdata_snippets/upload_appdata.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_upload_appdata]
import fs from 'node:fs';
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Uploads a file to the application data folder.
* @return {Promise<string>} The ID of the uploaded file.
*/
async function uploadAppdata() {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive.appdata',
});
// Create a new Drive API client.
const service = google.drive({version: 'v2', auth});
// The metadata for the file to be uploaded.
const fileMetadata = {
title: 'config.json',
parents: [
{
id: 'appDataFolder',
},
],
};
// The media content to be uploaded.
const media = {
mimeType: 'application/json',
body: fs.createReadStream('files/config.json'),
};
// Upload the file to the application data folder.
const file = await service.files.insert({
requestBody: fileMetadata,
media,
fields: 'id',
});
// Print the ID of the uploaded file.
console.log('File Id:', file.data.id);
if (!file.data.id) {
throw new Error('File ID not found.');
}
return file.data.id;
}
// [END drive_upload_appdata]
export {uploadAppdata};
================================================
FILE: drive/snippets/drive_v2/change_snippets/fetch_changes.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_fetch_changes]
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Fetches the list of changes for the currently authenticated user.
* @return {Promise<object[]>} A list of changes.
*/
async function fetchChanges() {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive',
});
// Create a new Drive API client.
const service = google.drive({version: 'v2', auth});
// The page token for the next page of changes. If not set, the first page is retrieved.
let pageToken;
// Fetch the list of changes.
const result = await service.changes.list({
pageToken,
fields: '*',
});
// Process the changes.
(result.data.items ?? []).forEach((change) => {
console.log('Change found for file:', change.fileId);
});
return result.data.items ?? [];
}
// [END drive_fetch_changes]
export {fetchChanges};
================================================
FILE: drive/snippets/drive_v2/change_snippets/fetch_start_page_token.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_fetch_start_page_token]
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Fetches the start page token for the current state of the user's account.
* @return {Promise<string>} The start page token.
*/
async function fetchStartPageToken() {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive',
});
// Create a new Drive API client.
const service = google.drive({version: 'v2', auth});
// Fetch the start page token.
const result = await service.changes.getStartPageToken();
console.log('Start token:', result.data.startPageToken);
if (!result.data.startPageToken) {
throw new Error('Start page token not found.');
}
return result.data.startPageToken;
}
// [END drive_fetch_start_page_token]
export {fetchStartPageToken};
================================================
FILE: drive/snippets/drive_v2/change_snippets/package.json
================================================
{
"name": "drive-snippets-drive-v2-change-snippets",
"version": "1.0.0",
"private": true,
"license": "Apache-2.0",
"type": "module",
"scripts": {
"check": "tsc --noEmit"
},
"devDependencies": {
"google-auth-library": "catalog:",
"typescript": "catalog:"
},
"engines": {
"node": ">=20"
},
"dependencies": {
"googleapis": "catalog:"
}
}
================================================
FILE: drive/snippets/drive_v2/change_snippets/tsconfig.json
================================================
{
"extends": "../../../../tsconfig.base.json",
"include": ["**/*.js"]
}
================================================
FILE: drive/snippets/drive_v2/drive_snippets/create_drive.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_create_drive]
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
import {v4 as uuid} from 'uuid';
/**
* Creates a new shared drive.
* @return {Promise<string>} The ID of the created shared drive.
*/
async function createDrive() {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive',
});
// Create a new Drive API client.
const service = google.drive({version: 'v2', auth});
// The metadata for the new shared drive.
const driveMetadata = {
name: 'Project resources',
};
// A unique request ID to avoid creating duplicate shared drives.
const requestId = uuid();
// Create the new shared drive.
const Drive = await service.drives.insert({
requestBody: driveMetadata,
requestId,
fields: 'id',
});
// Print the ID of the new shared drive.
console.log('Drive Id:', Drive.data.id);
if (!Drive.data.id) {
throw new Error('Drive ID not found.');
}
return Drive.data.id;
}
// [END drive_create_drive]
export {createDrive};
================================================
FILE: drive/snippets/drive_v2/drive_snippets/package.json
================================================
{
"name": "drive-snippets-drive-v2-drive-snippets",
"version": "1.0.0",
"private": true,
"license": "Apache-2.0",
"type": "module",
"scripts": {
"check": "tsc --noEmit"
},
"devDependencies": {
"@types/uuid": "catalog:",
"google-auth-library": "catalog:",
"typescript": "catalog:"
},
"engines": {
"node": ">=20"
},
"dependencies": {
"googleapis": "catalog:"
}
}
================================================
FILE: drive/snippets/drive_v2/drive_snippets/recover_drives.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_recover_drives]
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Finds all shared drives without an organizer and adds one.
* @param {string} userEmail The email of the user to make an organizer.
*/
async function recoverDrives(userEmail) {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive',
});
// Create a new Drive API client.
const service = google.drive({version: 'v2', auth});
// The permission to add to the shared drive.
const newOrganizerPermission = {
type: 'user',
role: 'organizer',
value: userEmail,
};
// List all shared drives with no organizers.
const result = await service.drives.list({
q: 'organizerCount = 0',
fields: 'nextPageToken, items(id, name)',
useDomainAdminAccess: true,
});
// Add the new organizer to each found shared drive.
for (const drive of result.data.items ?? []) {
if (!drive.id) {
continue;
}
console.log('Found shared drive without organizer:', drive.name, drive.id);
await service.permissions.insert({
requestBody: newOrganizerPermission,
fileId: drive.id,
useDomainAdminAccess: true,
supportsAllDrives: true,
fields: 'id',
});
}
}
// [END drive_recover_drives]
export {recoverDrives};
================================================
FILE: drive/snippets/drive_v2/drive_snippets/tsconfig.json
================================================
{
"extends": "../../../../tsconfig.base.json",
"include": ["**/*.js"]
}
================================================
FILE: drive/snippets/drive_v2/file snippets/create_folder.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_create_folder]
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Creates a new folder in Google Drive.
* @return {Promise<string>} The ID of the created folder.
*/
async function createFolder() {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive',
});
// Create a new Drive API client.
const service = google.drive({version: 'v2', auth});
// The metadata for the new folder.
const fileMetadata = {
title: 'Invoices',
mimeType: 'application/vnd.google-apps.folder',
};
// Create the new folder.
const file = await service.files.insert({
requestBody: fileMetadata,
fields: 'id',
});
// Print the ID of the new folder.
console.log('Folder Id:', file.data.id);
if (!file.data.id) {
throw new Error('File ID not found.');
}
return file.data.id;
}
// [END drive_create_folder]
export {createFolder};
================================================
FILE: drive/snippets/drive_v2/file snippets/create_shortcut.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_create_shortcut]
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Creates a shortcut to a third-party resource.
* @return {Promise<string>} The ID of the created shortcut.
*/
async function createShortcut() {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive',
});
// Create a new Drive API client.
const service = google.drive({version: 'v2', auth});
// The metadata for the new shortcut.
const fileMetadata = {
title: 'Project plan',
mimeType: 'application/vnd.google-apps.drive-sdk',
};
// Create the new shortcut.
const file = await service.files.insert({
requestBody: fileMetadata,
fields: 'id',
});
// Print the ID of the new shortcut.
console.log('File Id:', file.data.id);
if (!file.data.id) {
throw new Error('File ID not found.');
}
return file.data.id;
}
// [END drive_create_shortcut]
export {createShortcut};
================================================
FILE: drive/snippets/drive_v2/file snippets/download_file.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_download_file]
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Downloads a file from Google Drive.
* @param {string} fileId The ID of the file to download.
* @return {Promise<number>} The status of the download.
*/
async function downloadFile(fileId) {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive',
});
// Create a new Drive API client.
const service = google.drive({version: 'v2', auth});
// Download the file.
const file = await service.files.get({
fileId,
alt: 'media',
});
// Print the status of the download.
console.log(file.status);
return file.status;
}
// [END drive_download_file]
export {downloadFile};
================================================
FILE: drive/snippets/drive_v2/file snippets/export_pdf.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_export_pdf]
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Exports a Google Doc as a PDF.
* @param {string} fileId The ID of the file to export.
* @return {Promise<object>} The response from the export request.
*/
async function exportPdf(fileId) {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive',
});
// Create a new Drive API client.
const service = google.drive({version: 'v2', auth});
// Export the file as a PDF.
const result = await service.files.export({
fileId,
mimeType: 'application/pdf',
});
// Print the status of the export.
console.log(result.status);
return result;
}
// [END drive_export_pdf]
export {exportPdf};
================================================
FILE: drive/snippets/drive_v2/file snippets/move_file_to_folder.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_move_file_to_folder]
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Moves a file to a new folder in Google Drive.
* @param {string} fileId The ID of the file to move.
* @param {string} folderId The ID of the folder to move the file to.
* @return {Promise<number>} The status of the move operation.
*/
async function moveFileToFolder(fileId, folderId) {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive',
});
// Create a new Drive API client.
const service = google.drive({version: 'v2', auth});
// Get the file's metadata to retrieve its current parents.
const file = await service.files.get({
fileId,
fields: 'parents',
});
// Get the current parents as a comma-separated string.
const previousParents = (file.data.parents ?? [])
.map((parent) => parent.id)
.join(',');
// Move the file to the new folder.
const files = await service.files.update({
fileId,
addParents: folderId,
removeParents: previousParents,
fields: 'id, parents',
});
// Print the status of the move operation.
console.log(files.status);
return files.status;
}
// [END drive_move_file_to_folder]
export {moveFileToFolder};
================================================
FILE: drive/snippets/drive_v2/file snippets/package.json
================================================
{
"name": "drive-snippets-drive-v2-file-snippets",
"version": "1.0.0",
"private": true,
"license": "Apache-2.0",
"type": "module",
"scripts": {
"check": "tsc --noEmit"
},
"devDependencies": {
"google-auth-library": "catalog:",
"typescript": "catalog:"
},
"engines": {
"node": ">=20"
},
"dependencies": {
"googleapis": "catalog:"
}
}
================================================
FILE: drive/snippets/drive_v2/file snippets/search_file.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_search_file]
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Searches for files in Google Drive.
* @return {Promise<object[]>} A list of files.
*/
async function searchFile() {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive',
});
// Create a new Drive API client.
const service = google.drive({version: 'v2', auth});
// The page token for the next page of results. If not set, the first page is retrieved.
const pageToken = undefined;
// Search for files with the specified query.
const result = await service.files.list({
q: "mimeType='image/jpeg'",
fields: 'nextPageToken, items(id, title)',
spaces: 'drive',
pageToken,
});
// Print the title and ID of each found file.
(result.data.items ?? []).forEach((file) => {
console.log('Found file:', file.title, file.id);
});
return result.data.items ?? [];
}
// [END drive_search_file]
export {searchFile};
================================================
FILE: drive/snippets/drive_v2/file snippets/share_file.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_share_file]
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Shares a file with a user and a domain.
* @param {string} fileId The ID of the file to share.
* @param {string} targetUser The email address of the user to share with.
* @param {string} targetDomain The domain to share with.
* @return {Promise<string[]>} A list of the inserted permission IDs.
*/
async function shareFile(fileId, targetUser, targetDomain) {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive',
});
// Create a new Drive API client.
const service = google.drive({version: 'v2', auth});
const permissionIds = [];
// The permissions to insert.
const permissions = [
{
type: 'user',
role: 'writer',
value: targetUser, // e.g., 'user@example.com'
},
{
type: 'domain',
role: 'writer',
value: targetDomain, // e.g., 'example.com'
},
];
// Note: The client library does not currently support batch requests for permissions.
// When possible, use batch requests to insert multiple permissions on the same item.
for (const permission of permissions) {
// Insert the permission.
const result = await service.permissions.insert({
requestBody: permission,
fileId,
fields: 'id',
});
if (result.data.id) {
permissionIds.push(result.data.id);
console.log(`Inserted permission id: ${result.data.id}`);
} else {
throw new Error('Failed to create permission');
}
}
return permissionIds;
}
// [END drive_share_file]
export {shareFile};
================================================
FILE: drive/snippets/drive_v2/file snippets/touch_file.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_touch_file]
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Updates the modification timestamp of a file.
* @param {string} fileId The ID of the file to update.
* @param {string} timestamp The new modification timestamp.
* @return {Promise<string|null|undefined>} The updated modification timestamp.
*/
async function touchFile(fileId, timestamp) {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive',
});
// Create a new Drive API client.
const service = google.drive({version: 'v2', auth});
// The metadata to update.
const fileMetadata = {
modifiedDate: new Date().toISOString(),
modifiedTime: timestamp,
};
// Update the file's modification timestamp.
const file = await service.files.update({
fileId,
setModifiedDate: true,
requestBody: fileMetadata,
fields: 'id, modifiedDate',
});
// Print the new modification timestamp.
console.log('Modified time:', file.data.modifiedDate);
return file.data.modifiedDate;
}
// [END drive_touch_file]
export {touchFile};
================================================
FILE: drive/snippets/drive_v2/file snippets/tsconfig.json
================================================
{
"extends": "../../../../tsconfig.base.json",
"include": ["**/*.js"]
}
================================================
FILE: drive/snippets/drive_v2/file snippets/upload_basic.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_upload_basic]
import fs from 'node:fs';
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Uploads a file to Google Drive.
* @return {Promise<string>} The ID of the uploaded file.
*/
async function uploadBasic() {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive',
});
// Create a new Drive API client.
const service = google.drive({version: 'v2', auth});
// The metadata for the file to be uploaded.
const fileMetadata = {
title: 'photo.jpg',
};
// The media content to be uploaded.
const media = {
mimeType: 'image/jpeg',
body: fs.createReadStream('files/photo.jpg'),
};
// Upload the file.
const file = await service.files.insert({
requestBody: fileMetadata,
media,
fields: 'id',
});
// Print the ID of the uploaded file.
console.log('File Id:', file.data.id);
if (!file.data.id) {
throw new Error('File ID not found.');
}
return file.data.id;
}
// [END drive_upload_basic]
export {uploadBasic};
================================================
FILE: drive/snippets/drive_v2/file snippets/upload_to_folder.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_upload_to_folder]
import fs from 'node:fs';
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Uploads a file to a specific folder in Google Drive.
* @param {string} folderId The ID of the folder to upload the file to.
* @return {Promise<string>} The ID of the uploaded file.
*/
async function uploadToFolder(folderId) {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive',
});
// Create a new Drive API client.
const service = google.drive({version: 'v2', auth});
// The metadata for the file to be uploaded.
const fileMetadata = {
title: 'photo.jpg',
parents: [{id: folderId}],
};
// The media content to be uploaded.
const media = {
mimeType: 'image/jpeg',
body: fs.createReadStream('files/photo.jpg'),
};
// Upload the file to the specified folder.
const file = await service.files.insert({
requestBody: fileMetadata,
media,
fields: 'id',
});
// Print the ID of the uploaded file.
console.log('File Id:', file.data.id);
if (!file.data.id) {
throw new Error('File ID not found.');
}
return file.data.id;
}
// [END drive_upload_to_folder]
export {uploadToFolder};
================================================
FILE: drive/snippets/drive_v2/file snippets/upload_with_conversion.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_upload_with_conversion]
import fs from 'node:fs';
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Uploads a file to Google Drive and converts it to a Google Sheet.
* @return {Promise<string>} The ID of the uploaded file.
*/
async function uploadWithConversion() {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive',
});
// Create a new Drive API client.
const service = google.drive({version: 'v2', auth});
// The metadata for the file to be uploaded and converted.
const fileMetadata = {
title: 'My Report',
// The MIME type to convert the file to.
mimeType: 'application/vnd.google-apps.spreadsheet',
};
// The media content to be uploaded.
const media = {
mimeType: 'text/csv',
body: fs.createReadStream('files/report.csv'),
};
// Upload the file with conversion.
const file = await service.files.insert({
requestBody: fileMetadata,
media,
fields: 'id',
});
// Print the ID of the uploaded file.
console.log('File Id:', file.data.id);
if (!file.data.id) {
throw new Error('File ID not found.');
}
return file.data.id;
}
// [END drive_upload_with_conversion]
export {uploadWithConversion};
================================================
FILE: drive/snippets/drive_v3/appdata_snippets/fetch_appdata_folder.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_fetch_appdata_folder]
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Fetches the ID of the application data folder.
* @return {Promise<string>} The ID of the application data folder.
*/
async function fetchAppdataFolder() {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive.appdata',
});
// Create a new Drive API client (v3).
const service = google.drive({version: 'v3', auth});
// Get the application data folder.
const file = await service.files.get({
fileId: 'appDataFolder',
fields: 'id',
});
// Print the folder ID.
console.log('File Id:', file.data.id);
if (!file.data.id) {
throw new Error('File ID not found.');
}
return file.data.id;
}
// [END drive_fetch_appdata_folder]
export {fetchAppdataFolder};
================================================
FILE: drive/snippets/drive_v3/appdata_snippets/list_appdata.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_list_appdata]
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Lists all files in the application data folder.
* @return {Promise<object[]>} A list of files.
*/
async function listAppdata() {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive.appdata',
});
// Create a new Drive API client (v3).
const service = google.drive({version: 'v3', auth});
// List the files in the application data folder.
const result = await service.files.list({
spaces: 'appDataFolder',
fields: 'nextPageToken, files(id, name)',
pageSize: 100,
});
// Print the name and ID of each file.
(result.data.files ?? []).forEach((file) => {
console.log('Found file:', file.name, file.id);
});
return result.data.files ?? [];
}
// [END drive_list_appdata]
export {listAppdata};
================================================
FILE: drive/snippets/drive_v3/appdata_snippets/package.json
================================================
{
"name": "drive-snippets-drive-v3-appdata-snippets",
"version": "1.0.0",
"private": true,
"license": "Apache-2.0",
"type": "module",
"scripts": {
"check": "tsc --noEmit"
},
"devDependencies": {
"google-auth-library": "catalog:",
"typescript": "catalog:"
},
"engines": {
"node": ">=20"
},
"dependencies": {
"googleapis": "catalog:"
}
}
================================================
FILE: drive/snippets/drive_v3/appdata_snippets/tsconfig.json
================================================
{
"extends": "../../../../tsconfig.base.json",
"include": ["**/*.js"]
}
================================================
FILE: drive/snippets/drive_v3/appdata_snippets/upload_appdata.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_upload_appdata]
import fs from 'node:fs';
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Uploads a file to the application data folder.
* @return {Promise<string>} The ID of the uploaded file.
*/
async function uploadAppdata() {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive.appdata',
});
// Create a new Drive API client (v3).
const service = google.drive({version: 'v3', auth});
// The metadata for the file to be uploaded.
const fileMetadata = {
name: 'config.json',
parents: ['appDataFolder'],
};
// The media content to be uploaded.
const media = {
mimeType: 'application/json',
body: fs.createReadStream('files/config.json'),
};
// Upload the file to the application data folder.
const file = await service.files.create({
requestBody: fileMetadata,
media,
fields: 'id',
});
// Print the ID of the uploaded file.
console.log('File Id:', file.data.id);
if (!file.data.id) {
throw new Error('File ID not found.');
}
return file.data.id;
}
// [END drive_upload_appdata]
export {uploadAppdata};
================================================
FILE: drive/snippets/drive_v3/change_snippets/fetch_changes.js
================================================
/**
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// [START drive_fetch_changes]
import {GoogleAuth} from 'google-auth-library';
import {google} from 'googleapis';
/**
* Fetches the list of changes for the currently authenticated user.
* @param {string} savedStartPageToken The page token obtained from `fetch_start_page_token.js`.
*/
async function fetchChanges(savedStartPageToken) {
// Authenticate with Google and get an authorized client.
// TODO (developer): Use an appropriate auth mechanism for your app.
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/drive.readonly',
});
// Create a new Drive API client (v3).
const service = google
gitextract_b64kqjz8/ ├── .gemini/ │ ├── GEMINI.md │ ├── config.yaml │ └── settings.json ├── .github/ │ ├── CODEOWNERS │ ├── ISSUE_TEMPLATE.md │ ├── dependabot.yml │ ├── snippet-bot.yml │ ├── sync-repo-settings.yaml │ └── workflows/ │ ├── automation.yml │ ├── lint.yml │ └── test.yml ├── .gitignore ├── .vscode/ │ └── extensions.json ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── adminSDK/ │ ├── directory/ │ │ ├── index.js │ │ ├── package.json │ │ └── tsconfig.json │ ├── reports/ │ │ ├── index.js │ │ ├── package.json │ │ └── tsconfig.json │ └── reseller/ │ ├── index.js │ ├── package.json │ └── tsconfig.json ├── apps-script/ │ ├── execute/ │ │ ├── index.js │ │ ├── package.json │ │ └── tsconfig.json │ └── quickstart/ │ ├── index.js │ ├── package.json │ └── tsconfig.json ├── biome.json ├── calendar/ │ └── quickstart/ │ ├── index.js │ ├── package.json │ └── tsconfig.json ├── chat/ │ ├── client-libraries/ │ │ └── cloud/ │ │ ├── authentication-utils.js │ │ ├── create-custom-emoji-user-cred.js │ │ ├── create-membership-user-cred-for-app.js │ │ ├── create-membership-user-cred-for-group.js │ │ ├── create-membership-user-cred.js │ │ ├── create-message-app-cred.js │ │ ├── create-message-user-cred-at-mention.js │ │ ├── create-message-user-cred-message-id.js │ │ ├── create-message-user-cred-request-id.js │ │ ├── create-message-user-cred-thread-key.js │ │ ├── create-message-user-cred-thread-name.js │ │ ├── create-message-user-cred.js │ │ ├── create-reaction-user-cred.js │ │ ├── create-space-user-cred.js │ │ ├── delete-custom-emoji-user-cred.js │ │ ├── delete-membership-user-cred.js │ │ ├── delete-message-app-cred.js │ │ ├── delete-message-user-cred.js │ │ ├── delete-reaction-user-cred.js │ │ ├── delete-space-user-cred.js │ │ ├── find-dm-space-app-cred.js │ │ ├── find-dm-space-user-cred.js │ │ ├── get-attachment-app-cred.js │ │ ├── get-custom-emoji-user-cred.js │ │ ├── get-membership-app-cred.js │ │ ├── get-membership-user-cred.js │ │ ├── get-message-app-cred.js │ │ ├── get-message-user-cred.js │ │ ├── get-space-app-cred.js │ │ ├── get-space-event-user-cred.js │ │ ├── get-space-notification-setting-user-cred.js │ │ ├── get-space-read-state-user-cred.js │ │ ├── get-space-user-cred.js │ │ ├── get-thread-read-state-user-cred.js │ │ ├── list-custom-emojis-user-cred.js │ │ ├── list-memberships-app-cred.js │ │ ├── list-memberships-user-cred.js │ │ ├── list-messages-user-cred.js │ │ ├── list-reactions-user-cred.js │ │ ├── list-space-events-user-cred.js │ │ ├── list-spaces-app-cred.js │ │ ├── list-spaces-user-cred.js │ │ ├── package.json │ │ ├── set-up-space-user-cred.js │ │ ├── tsconfig.json │ │ ├── update-membership-user-cred.js │ │ ├── update-message-app-cred.js │ │ ├── update-message-user-cred.js │ │ ├── update-space-notification-setting-user-cred.js │ │ ├── update-space-read-state-user-cred.js │ │ └── update-space-user-cred.js │ └── quickstart/ │ ├── index.js │ ├── package.json │ └── tsconfig.json ├── classroom/ │ └── quickstart/ │ ├── index.js │ ├── package.json │ └── tsconfig.json ├── docs/ │ └── quickstart/ │ ├── index.js │ ├── package.json │ └── tsconfig.json ├── drive/ │ ├── activity-v2/ │ │ ├── index.js │ │ ├── package.json │ │ └── tsconfig.json │ ├── quickstart/ │ │ ├── index.js │ │ ├── package.json │ │ └── tsconfig.json │ └── snippets/ │ ├── drive_v2/ │ │ ├── appdata_snippets/ │ │ │ ├── fetch_appdata_folder.js │ │ │ ├── list_appdata.js │ │ │ ├── package.json │ │ │ ├── tsconfig.json │ │ │ └── upload_appdata.js │ │ ├── change_snippets/ │ │ │ ├── fetch_changes.js │ │ │ ├── fetch_start_page_token.js │ │ │ ├── package.json │ │ │ └── tsconfig.json │ │ ├── drive_snippets/ │ │ │ ├── create_drive.js │ │ │ ├── package.json │ │ │ ├── recover_drives.js │ │ │ └── tsconfig.json │ │ └── file snippets/ │ │ ├── create_folder.js │ │ ├── create_shortcut.js │ │ ├── download_file.js │ │ ├── export_pdf.js │ │ ├── move_file_to_folder.js │ │ ├── package.json │ │ ├── search_file.js │ │ ├── share_file.js │ │ ├── touch_file.js │ │ ├── tsconfig.json │ │ ├── upload_basic.js │ │ ├── upload_to_folder.js │ │ └── upload_with_conversion.js │ ├── drive_v3/ │ │ ├── appdata_snippets/ │ │ │ ├── fetch_appdata_folder.js │ │ │ ├── list_appdata.js │ │ │ ├── package.json │ │ │ ├── tsconfig.json │ │ │ └── upload_appdata.js │ │ ├── change_snippets/ │ │ │ ├── fetch_changes.js │ │ │ ├── fetch_start_page_token.js │ │ │ ├── package.json │ │ │ └── tsconfig.json │ │ ├── drive_snippets/ │ │ │ ├── create_drive.js │ │ │ ├── package.json │ │ │ ├── recover_drives.js │ │ │ └── tsconfig.json │ │ └── file_snippets/ │ │ ├── create_folder.js │ │ ├── create_shortcut.js │ │ ├── download_file.js │ │ ├── export_pdf.js │ │ ├── move_file_to_folder.js │ │ ├── package.json │ │ ├── search_file.js │ │ ├── share_file.js │ │ ├── touch_file.js │ │ ├── tsconfig.json │ │ ├── upload_basic.js │ │ ├── upload_to_folder.js │ │ └── upload_with_conversion.js │ ├── files/ │ │ ├── config.json │ │ ├── document.txt │ │ └── report.csv │ └── test/ │ ├── helpers.js │ ├── test_drive_v2_create_drive.js │ ├── test_drive_v2_create_folder.js │ ├── test_drive_v2_create_shortcut.js │ ├── test_drive_v2_download_file.js │ ├── test_drive_v2_export_pdf.js │ ├── test_drive_v2_fetch_appdata_folder.js │ ├── test_drive_v2_fetch_changes.js │ ├── test_drive_v2_fetch_start_page_token.js │ ├── test_drive_v2_list_appdata.js │ ├── test_drive_v2_move_file_to_folder.js │ ├── test_drive_v2_recover_drives.js │ ├── test_drive_v2_search_file.js │ ├── test_drive_v2_share_file.js │ ├── test_drive_v2_touch_file.js │ ├── test_drive_v2_upload_appdata.js │ ├── test_drive_v2_upload_basic.js │ ├── test_drive_v2_upload_to_folder.js │ ├── test_drive_v2_upload_with_conversion.js │ ├── test_drive_v3_create_drive.js │ ├── test_drive_v3_create_folder.js │ ├── test_drive_v3_create_shortcut.js │ ├── test_drive_v3_download_file.js │ ├── test_drive_v3_export_pdf.js │ ├── test_drive_v3_fetch_appdata_folder.js │ ├── test_drive_v3_fetch_changes.js │ ├── test_drive_v3_fetch_start_page_token.js │ ├── test_drive_v3_list_appdata.js │ ├── test_drive_v3_move_file_to_folder.js │ ├── test_drive_v3_recover_drives.js │ ├── test_drive_v3_search_file.js │ ├── test_drive_v3_share_file.js │ ├── test_drive_v3_touch_file.js │ ├── test_drive_v3_upload_appdata.js │ ├── test_drive_v3_upload_basic.js │ ├── test_drive_v3_upload_to_folder.js │ └── test_drive_v3_upload_with_conversion.js ├── forms/ │ └── snippets/ │ ├── add_item.js │ ├── add_responder.js │ ├── anyone_with_link_responder.js │ ├── convert_form.js │ ├── create_form.js │ ├── create_watch.js │ ├── delete_watch.js │ ├── get_all_responses.js │ ├── get_form.js │ ├── get_responders.js │ ├── get_single_response.js │ ├── list_watches.js │ ├── package.json │ ├── publish_form.js │ ├── remove_responders.js │ ├── renew_watch.js │ ├── stop_accepting_responses.js │ ├── supports_publishing.js │ ├── tsconfig.json │ ├── unpublish_form.js │ └── update_form.js ├── gmail/ │ └── quickstart/ │ ├── index.js │ ├── package.json │ └── tsconfig.json ├── meet/ │ ├── README.md │ └── quickstart/ │ ├── index.js │ ├── package.json │ └── tsconfig.json ├── package.json ├── people/ │ └── quickstart/ │ ├── index.js │ ├── package.json │ └── tsconfig.json ├── pnpm-workspace.yaml ├── sheets/ │ ├── quickstart/ │ │ ├── index.js │ │ ├── package.json │ │ └── tsconfig.json │ └── snippets/ │ ├── package.json │ ├── sheets_append_values.js │ ├── sheets_batch_get_values.js │ ├── sheets_batch_update.js │ ├── sheets_batch_update_values.js │ ├── sheets_conditional_formatting.js │ ├── sheets_create.js │ ├── sheets_get_values.js │ ├── sheets_pivot_table.js │ ├── sheets_update_values.js │ ├── test/ │ │ ├── helpers.js │ │ ├── test_sheets_append_values.js │ │ ├── test_sheets_batch_get_values.js │ │ ├── test_sheets_batch_update.js │ │ ├── test_sheets_batch_update_values.js │ │ ├── test_sheets_conditional_formatting.js │ │ ├── test_sheets_create.js │ │ ├── test_sheets_get_values.js │ │ ├── test_sheets_pivot_table.js │ │ └── test_sheets_update_values.js │ └── tsconfig.json ├── slides/ │ ├── quickstart/ │ │ ├── index.js │ │ ├── package.json │ │ └── tsconfig.json │ └── snippets/ │ ├── package.json │ ├── slides_copy_presentation.js │ ├── slides_create_bulleted_text.js │ ├── slides_create_image.js │ ├── slides_create_presentation.js │ ├── slides_create_sheets_chart.js │ ├── slides_create_slide.js │ ├── slides_create_textbox_with_text.js │ ├── slides_image_merging.js │ ├── slides_refresh_sheets_chart.js │ ├── slides_simple_text_replace.js │ ├── slides_text_merging.js │ ├── slides_text_style_update.js │ ├── test/ │ │ ├── helpers.js │ │ ├── test_slides_copy_presentation.js │ │ ├── test_slides_create_bulleted_text.js │ │ ├── test_slides_create_image.js │ │ ├── test_slides_create_presentation.js │ │ ├── test_slides_create_sheets_chart.js │ │ ├── test_slides_create_slide.js │ │ ├── test_slides_create_textbox_with_text.js │ │ ├── test_slides_image_merging.js │ │ ├── test_slides_refresh_sheets_chart.js │ │ ├── test_slides_simple_text_replace.js │ │ ├── test_slides_text_merging.js │ │ └── test_slides_text_style_update.js │ └── tsconfig.json ├── solutions/ │ └── webhook-chat-app/ │ ├── README.md │ ├── index.js │ ├── package.json │ └── thread-reply.js ├── tasks/ │ └── quickstart/ │ ├── index.js │ ├── package.json │ └── tsconfig.json ├── tsconfig.base.json └── turbo.json
SYMBOL INDEX (274 symbols across 153 files)
FILE: adminSDK/directory/index.js
constant SCOPES (line 25) | const SCOPES = ['https://www.googleapis.com/auth/admin.directory.user'];
constant CREDENTIALS_PATH (line 27) | const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
function listUsers (line 32) | async function listUsers() {
FILE: adminSDK/reports/index.js
constant SCOPES (line 25) | const SCOPES = ['https://www.googleapis.com/auth/admin.reports.audit.rea...
constant CREDENTIALS_PATH (line 27) | const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
function listLoginEvents (line 32) | async function listLoginEvents() {
FILE: adminSDK/reseller/index.js
constant SCOPES (line 25) | const SCOPES = ['https://www.googleapis.com/auth/apps.order'];
constant CREDENTIALS_PATH (line 27) | const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
function listSubscriptions (line 32) | async function listSubscriptions() {
FILE: apps-script/execute/index.js
function callAppsScript (line 25) | async function callAppsScript() {
FILE: apps-script/quickstart/index.js
constant SCOPES (line 24) | const SCOPES = ['https://www.googleapis.com/auth/script.projects'];
constant CREDENTIALS_PATH (line 25) | const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
function callAppsScript (line 30) | async function callAppsScript() {
FILE: calendar/quickstart/index.js
constant SCOPES (line 25) | const SCOPES = ['https://www.googleapis.com/auth/calendar.readonly'];
constant CREDENTIALS_PATH (line 27) | const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
function listEvents (line 32) | async function listEvents() {
FILE: chat/client-libraries/cloud/authentication-utils.js
constant SERVICE_ACCOUNT_FILE (line 28) | const SERVICE_ACCOUNT_FILE = './service_account.json';
constant APP_AUTH_OAUTH_SCOPES (line 29) | const APP_AUTH_OAUTH_SCOPES = ['https://www.googleapis.com/auth/chat.bot'];
constant CLIENT_SECRETS_FILE (line 32) | const CLIENT_SECRETS_FILE = './credentials.json';
constant CLIENT_SECRETS (line 33) | const CLIENT_SECRETS = JSON.parse(
function createClientWithAppCredentials (line 42) | function createClientWithAppCredentials() {
function createClientWithUserCredentials (line 57) | async function createClientWithUserCredentials(scopes) {
function getAuthenticatedUserOAuth2Client (line 72) | function getAuthenticatedUserOAuth2Client(scopes) {
FILE: chat/client-libraries/cloud/create-custom-emoji-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/create-membership-user-cred-for-app.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/create-membership-user-cred-for-group.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/create-membership-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 28) | async function main() {
FILE: chat/client-libraries/cloud/create-message-app-cred.js
function main (line 23) | async function main() {
FILE: chat/client-libraries/cloud/create-message-user-cred-at-mention.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 28) | async function main() {
FILE: chat/client-libraries/cloud/create-message-user-cred-message-id.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 28) | async function main() {
FILE: chat/client-libraries/cloud/create-message-user-cred-request-id.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/create-message-user-cred-thread-key.js
constant USER_AUTH_OAUTH_SCOPES (line 23) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 28) | async function main() {
FILE: chat/client-libraries/cloud/create-message-user-cred-thread-name.js
constant USER_AUTH_OAUTH_SCOPES (line 23) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 29) | async function main() {
FILE: chat/client-libraries/cloud/create-message-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/create-reaction-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/create-space-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/delete-custom-emoji-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/delete-membership-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 28) | async function main() {
FILE: chat/client-libraries/cloud/delete-message-app-cred.js
function main (line 23) | async function main() {
FILE: chat/client-libraries/cloud/delete-message-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/delete-reaction-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/delete-space-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = ['https://www.googleapis.com/auth/chat.de...
function main (line 25) | async function main() {
FILE: chat/client-libraries/cloud/find-dm-space-app-cred.js
function main (line 23) | async function main() {
FILE: chat/client-libraries/cloud/find-dm-space-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/get-attachment-app-cred.js
function main (line 24) | async function main() {
FILE: chat/client-libraries/cloud/get-custom-emoji-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/get-membership-app-cred.js
function main (line 23) | async function main() {
FILE: chat/client-libraries/cloud/get-membership-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/get-message-app-cred.js
function main (line 23) | async function main() {
FILE: chat/client-libraries/cloud/get-message-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/get-space-app-cred.js
function main (line 23) | async function main() {
FILE: chat/client-libraries/cloud/get-space-event-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = ['SCOPE_NAME'];
function main (line 25) | async function main() {
FILE: chat/client-libraries/cloud/get-space-notification-setting-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 28) | async function main() {
FILE: chat/client-libraries/cloud/get-space-read-state-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/get-space-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/get-thread-read-state-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 28) | async function main() {
FILE: chat/client-libraries/cloud/list-custom-emojis-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/list-memberships-app-cred.js
function main (line 23) | async function main() {
FILE: chat/client-libraries/cloud/list-memberships-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/list-messages-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/list-reactions-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/list-space-events-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 23) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 29) | async function main() {
FILE: chat/client-libraries/cloud/list-spaces-app-cred.js
function main (line 23) | async function main() {
FILE: chat/client-libraries/cloud/list-spaces-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/set-up-space-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 28) | async function main() {
FILE: chat/client-libraries/cloud/update-membership-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/update-message-app-cred.js
function main (line 23) | async function main() {
FILE: chat/client-libraries/cloud/update-message-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/update-space-notification-setting-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 28) | async function main() {
FILE: chat/client-libraries/cloud/update-space-read-state-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = [
function main (line 27) | async function main() {
FILE: chat/client-libraries/cloud/update-space-user-cred.js
constant USER_AUTH_OAUTH_SCOPES (line 22) | const USER_AUTH_OAUTH_SCOPES = ['https://www.googleapis.com/auth/chat.sp...
function main (line 25) | async function main() {
FILE: chat/quickstart/index.js
constant SCOPES (line 25) | const SCOPES = ['https://www.googleapis.com/auth/chat.spaces.readonly'];
constant CREDENTIALS_PATH (line 27) | const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
function listSpaces (line 32) | async function listSpaces() {
FILE: classroom/quickstart/index.js
constant SCOPES (line 25) | const SCOPES = ['https://www.googleapis.com/auth/classroom.courses.reado...
constant CREDENTIALS_PATH (line 27) | const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
function listCourses (line 32) | async function listCourses() {
FILE: docs/quickstart/index.js
constant SCOPES (line 25) | const SCOPES = ['https://www.googleapis.com/auth/documents.readonly'];
constant CREDENTIALS_PATH (line 27) | const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
function printDocTitle (line 33) | async function printDocTitle() {
FILE: drive/activity-v2/index.js
constant SCOPES (line 25) | const SCOPES = ['https://www.googleapis.com/auth/drive.activity.readonly'];
constant CREDENTIALS_PATH (line 27) | const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
function listDriveActivity (line 32) | async function listDriveActivity() {
FILE: drive/quickstart/index.js
constant SCOPES (line 25) | const SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly'];
constant CREDENTIALS_PATH (line 27) | const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
function listFiles (line 32) | async function listFiles() {
FILE: drive/snippets/drive_v2/appdata_snippets/fetch_appdata_folder.js
function fetchAppdataFolder (line 26) | async function fetchAppdataFolder() {
FILE: drive/snippets/drive_v2/appdata_snippets/list_appdata.js
function listAppdata (line 26) | async function listAppdata() {
FILE: drive/snippets/drive_v2/appdata_snippets/upload_appdata.js
function uploadAppdata (line 27) | async function uploadAppdata() {
FILE: drive/snippets/drive_v2/change_snippets/fetch_changes.js
function fetchChanges (line 26) | async function fetchChanges() {
FILE: drive/snippets/drive_v2/change_snippets/fetch_start_page_token.js
function fetchStartPageToken (line 26) | async function fetchStartPageToken() {
FILE: drive/snippets/drive_v2/drive_snippets/create_drive.js
function createDrive (line 27) | async function createDrive() {
FILE: drive/snippets/drive_v2/drive_snippets/recover_drives.js
function recoverDrives (line 26) | async function recoverDrives(userEmail) {
FILE: drive/snippets/drive_v2/file snippets/create_folder.js
function createFolder (line 26) | async function createFolder() {
FILE: drive/snippets/drive_v2/file snippets/create_shortcut.js
function createShortcut (line 26) | async function createShortcut() {
FILE: drive/snippets/drive_v2/file snippets/download_file.js
function downloadFile (line 27) | async function downloadFile(fileId) {
FILE: drive/snippets/drive_v2/file snippets/export_pdf.js
function exportPdf (line 27) | async function exportPdf(fileId) {
FILE: drive/snippets/drive_v2/file snippets/move_file_to_folder.js
function moveFileToFolder (line 28) | async function moveFileToFolder(fileId, folderId) {
FILE: drive/snippets/drive_v2/file snippets/search_file.js
function searchFile (line 26) | async function searchFile() {
FILE: drive/snippets/drive_v2/file snippets/share_file.js
function shareFile (line 29) | async function shareFile(fileId, targetUser, targetDomain) {
FILE: drive/snippets/drive_v2/file snippets/touch_file.js
function touchFile (line 28) | async function touchFile(fileId, timestamp) {
FILE: drive/snippets/drive_v2/file snippets/upload_basic.js
function uploadBasic (line 27) | async function uploadBasic() {
FILE: drive/snippets/drive_v2/file snippets/upload_to_folder.js
function uploadToFolder (line 28) | async function uploadToFolder(folderId) {
FILE: drive/snippets/drive_v2/file snippets/upload_with_conversion.js
function uploadWithConversion (line 27) | async function uploadWithConversion() {
FILE: drive/snippets/drive_v3/appdata_snippets/fetch_appdata_folder.js
function fetchAppdataFolder (line 26) | async function fetchAppdataFolder() {
FILE: drive/snippets/drive_v3/appdata_snippets/list_appdata.js
function listAppdata (line 26) | async function listAppdata() {
FILE: drive/snippets/drive_v3/appdata_snippets/upload_appdata.js
function uploadAppdata (line 27) | async function uploadAppdata() {
FILE: drive/snippets/drive_v3/change_snippets/fetch_changes.js
function fetchChanges (line 26) | async function fetchChanges(savedStartPageToken) {
FILE: drive/snippets/drive_v3/change_snippets/fetch_start_page_token.js
function fetchStartPageToken (line 26) | async function fetchStartPageToken() {
FILE: drive/snippets/drive_v3/drive_snippets/create_drive.js
function createDrive (line 27) | async function createDrive() {
FILE: drive/snippets/drive_v3/drive_snippets/recover_drives.js
function recoverDrives (line 27) | async function recoverDrives(userEmail) {
FILE: drive/snippets/drive_v3/file_snippets/create_folder.js
function createFolder (line 26) | async function createFolder() {
FILE: drive/snippets/drive_v3/file_snippets/create_shortcut.js
function createShortcut (line 26) | async function createShortcut() {
FILE: drive/snippets/drive_v3/file_snippets/download_file.js
function downloadFile (line 27) | async function downloadFile(fileId) {
FILE: drive/snippets/drive_v3/file_snippets/export_pdf.js
function exportPdf (line 27) | async function exportPdf(fileId) {
FILE: drive/snippets/drive_v3/file_snippets/move_file_to_folder.js
function moveFileToFolder (line 28) | async function moveFileToFolder(fileId, folderId) {
FILE: drive/snippets/drive_v3/file_snippets/search_file.js
function searchFile (line 26) | async function searchFile() {
FILE: drive/snippets/drive_v3/file_snippets/share_file.js
function shareFile (line 29) | async function shareFile(fileId, targetUserEmail, targetDomainName) {
FILE: drive/snippets/drive_v3/file_snippets/touch_file.js
function touchFile (line 28) | async function touchFile(fileId, timestamp) {
FILE: drive/snippets/drive_v3/file_snippets/upload_basic.js
function uploadBasic (line 27) | async function uploadBasic() {
FILE: drive/snippets/drive_v3/file_snippets/upload_to_folder.js
function uploadToFolder (line 28) | async function uploadToFolder(folderId) {
FILE: drive/snippets/drive_v3/file_snippets/upload_with_conversion.js
function uploadWithConversion (line 27) | async function uploadWithConversion() {
FILE: drive/snippets/test/helpers.js
class Helpers (line 24) | class Helpers {
method constructor (line 28) | constructor() {
method reset (line 39) | reset() {
method deleteFileOnCleanup (line 47) | deleteFileOnCleanup(id) {
method cleanup (line 55) | cleanup() {
method createFile (line 67) | async createFile(fileMetadata, media) {
method createTestDocument (line 82) | createTestDocument() {
method createTestBlob (line 99) | async createTestBlob() {
FILE: drive/snippets/test/test_drive_v2_recover_drives.js
function createOrphanedTeamDrive (line 41) | async function createOrphanedTeamDrive() {
FILE: drive/snippets/test/test_drive_v3_recover_drives.js
function createOrphanedTeamDrive (line 41) | async function createOrphanedTeamDrive() {
FILE: forms/snippets/add_item.js
function addItem (line 23) | async function addItem() {
FILE: forms/snippets/add_responder.js
constant CREDENTIALS_PATH (line 20) | const CREDENTIALS_PATH = path.join(__dirname, 'credentials.json');
constant SCOPES (line 21) | const SCOPES = ['https://www.googleapis.com/auth/drive.file'];
function addResponder (line 30) | async function addResponder(formId, email) {
FILE: forms/snippets/anyone_with_link_responder.js
constant CREDENTIALS_PATH (line 20) | const CREDENTIALS_PATH = path.join(__dirname, 'credentials.json');
constant SCOPES (line 21) | const SCOPES = ['https://www.googleapis.com/auth/drive.file'];
function isAnyoneWithLinkResponder (line 29) | async function isAnyoneWithLinkResponder(formId) {
function setAnyoneWithLinkResponder (line 88) | async function setAnyoneWithLinkResponder(formId) {
function removeAnyoneWithLinkResponder (line 129) | async function removeAnyoneWithLinkResponder(formId) {
FILE: forms/snippets/convert_form.js
function convertForm (line 23) | async function convertForm() {
FILE: forms/snippets/create_form.js
function createForm (line 23) | async function createForm() {
FILE: forms/snippets/create_watch.js
function createWatch (line 26) | async function createWatch() {
FILE: forms/snippets/delete_watch.js
function deleteWatch (line 28) | async function deleteWatch() {
FILE: forms/snippets/get_all_responses.js
function getAllResponses (line 26) | async function getAllResponses() {
FILE: forms/snippets/get_form.js
function getForm (line 26) | async function getForm() {
FILE: forms/snippets/get_responders.js
constant CREDENTIALS_PATH (line 20) | const CREDENTIALS_PATH = path.join(__dirname, 'credentials.json');
constant SCOPES (line 21) | const SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly'];
function getResponders (line 29) | async function getResponders(formId) {
FILE: forms/snippets/get_single_response.js
function getSingleResponse (line 28) | async function getSingleResponse() {
FILE: forms/snippets/list_watches.js
function listWatches (line 26) | async function listWatches() {
FILE: forms/snippets/publish_form.js
constant CREDENTIALS_PATH (line 20) | const CREDENTIALS_PATH = path.join(__dirname, 'credentials.json');
constant SCOPES (line 21) | const SCOPES = 'https://www.googleapis.com/auth/forms.body';
function publishForm (line 28) | async function publishForm(formIdToPublish) {
FILE: forms/snippets/remove_responders.js
constant CREDENTIALS_PATH (line 20) | const CREDENTIALS_PATH = path.join(__dirname, 'credentials.json');
constant SCOPES (line 21) | const SCOPES = ['https://www.googleapis.com/auth/drive.file'];
function removeResponders (line 30) | async function removeResponders(formId, email) {
FILE: forms/snippets/renew_watch.js
function renewWatch (line 28) | async function renewWatch() {
FILE: forms/snippets/stop_accepting_responses.js
constant CREDENTIALS_PATH (line 20) | const CREDENTIALS_PATH = path.join(__dirname, 'credentials.json');
constant SCOPES (line 21) | const SCOPES = 'https://www.googleapis.com/auth/forms.body';
function stopAcceptingResponses (line 28) | async function stopAcceptingResponses(formId) {
FILE: forms/snippets/supports_publishing.js
constant CREDENTIALS_PATH (line 20) | const CREDENTIALS_PATH = path.join(__dirname, 'credentials.json');
constant SCOPES (line 21) | const SCOPES = 'https://www.googleapis.com/auth/forms.body';
function supportsPublishing (line 28) | async function supportsPublishing(formIdToCheck) {
FILE: forms/snippets/unpublish_form.js
constant CREDENTIALS_PATH (line 20) | const CREDENTIALS_PATH = path.join(__dirname, 'credentials.json');
constant SCOPES (line 21) | const SCOPES = 'https://www.googleapis.com/auth/forms.body';
function unpublishForm (line 28) | async function unpublishForm(formIdToUnpublish) {
FILE: forms/snippets/update_form.js
function updateForm (line 23) | async function updateForm() {
FILE: gmail/quickstart/index.js
constant SCOPES (line 25) | const SCOPES = ['https://www.googleapis.com/auth/gmail.readonly'];
constant CREDENTIALS_PATH (line 27) | const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
function listLabels (line 32) | async function listLabels() {
FILE: meet/quickstart/index.js
constant SCOPES (line 25) | const SCOPES = ['https://www.googleapis.com/auth/meetings.space.created'];
constant CREDENTIALS_PATH (line 27) | const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
function createSpace (line 32) | async function createSpace() {
FILE: people/quickstart/index.js
constant SCOPES (line 25) | const SCOPES = ['https://www.googleapis.com/auth/contacts.readonly'];
constant CREDENTIALS_PATH (line 27) | const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
function listConnectionNames (line 32) | async function listConnectionNames() {
FILE: sheets/quickstart/index.js
constant SCOPES (line 25) | const SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly'];
constant CREDENTIALS_PATH (line 27) | const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
function listMajors (line 33) | async function listMajors() {
FILE: sheets/snippets/sheets_append_values.js
function appendValues (line 29) | async function appendValues(spreadsheetId, range, valueInputOption, _val...
FILE: sheets/snippets/sheets_batch_get_values.js
function batchGetValues (line 27) | async function batchGetValues(spreadsheetId, _ranges) {
FILE: sheets/snippets/sheets_batch_update.js
function batchUpdate (line 30) | async function batchUpdate(spreadsheetId, title, find, replacement) {
FILE: sheets/snippets/sheets_batch_update_values.js
function batchUpdateValues (line 29) | async function batchUpdateValues(
FILE: sheets/snippets/sheets_conditional_formatting.js
function conditionalFormatting (line 26) | async function conditionalFormatting(spreadsheetId) {
FILE: sheets/snippets/sheets_create.js
function create (line 26) | async function create(title) {
FILE: sheets/snippets/sheets_get_values.js
function getValues (line 27) | async function getValues(spreadsheetId, range) {
FILE: sheets/snippets/sheets_pivot_table.js
function pivotTable (line 26) | async function pivotTable(spreadsheetId) {
FILE: sheets/snippets/sheets_update_values.js
function updateValues (line 29) | async function updateValues(spreadsheetId, range, valueInputOption, _val...
FILE: sheets/snippets/test/helpers.js
class Helpers (line 23) | class Helpers {
method constructor (line 27) | constructor() {
method reset (line 42) | reset() {
method deleteFileOnCleanup (line 50) | deleteFileOnCleanup(id) {
method cleanup (line 58) | cleanup() {
method createTestSpreadsheet (line 70) | async createTestSpreadsheet() {
method populateValues (line 88) | async populateValues(spreadsheetId) {
FILE: slides/quickstart/index.js
constant SCOPES (line 25) | const SCOPES = ['https://www.googleapis.com/auth/presentations.readonly'];
constant CREDENTIALS_PATH (line 27) | const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
function listSlides (line 33) | async function listSlides() {
FILE: slides/snippets/slides_copy_presentation.js
function copyPresentation (line 27) | async function copyPresentation(presentationId, copyTitle) {
FILE: slides/snippets/slides_create_bulleted_text.js
function createBulletedText (line 27) | async function createBulletedText(presentationId, shapeId) {
FILE: slides/snippets/slides_create_image.js
function createImage (line 27) | async function createImage(presentationId, pageId) {
FILE: slides/snippets/slides_create_presentation.js
function createPresentation (line 26) | async function createPresentation(title) {
FILE: slides/snippets/slides_create_sheets_chart.js
function createSheetsChart (line 29) | async function createSheetsChart(
FILE: slides/snippets/slides_create_slide.js
function createSlide (line 27) | async function createSlide(presentationId, pageId) {
FILE: slides/snippets/slides_create_textbox_with_text.js
function createTextboxWithText (line 27) | async function createTextboxWithText(presentationId, pageId) {
FILE: slides/snippets/slides_image_merging.js
function imageMerging (line 28) | async function imageMerging(templatePresentationId, imageUrl, customerNa...
FILE: slides/snippets/slides_refresh_sheets_chart.js
function refreshSheetsChart (line 27) | async function refreshSheetsChart(presentationId, presentationChartId) {
FILE: slides/snippets/slides_simple_text_replace.js
function simpleTextReplace (line 28) | async function simpleTextReplace(presentationId, shapeId, replacementTex...
FILE: slides/snippets/slides_text_merging.js
function textMerging (line 26) | async function textMerging(templatePresentationId, dataSpreadsheetId) {
FILE: slides/snippets/slides_text_style_update.js
function textStyleUpdate (line 27) | async function textStyleUpdate(presentationId, shapeId) {
FILE: slides/snippets/test/helpers.js
class Helpers (line 23) | class Helpers {
method constructor (line 27) | constructor() {
method reset (line 44) | reset() {
method deleteFileOnCleanup (line 52) | deleteFileOnCleanup(id) {
method cleanup (line 60) | cleanup() {
method createTestPresentation (line 72) | async createTestPresentation() {
method addSlides (line 87) | async addSlides(presentationId, num, predefinedLayout) {
method createTestTextbox (line 116) | async createTestTextbox(presentationId, pageObjectId) {
method createTestSheetsChart (line 168) | async createTestSheetsChart(
method createTestSpreadsheet (line 217) | async createTestSpreadsheet() {
method populateValues (line 236) | async populateValues(spreadsheetId) {
FILE: slides/snippets/test/test_slides_create_sheets_chart.js
constant CHART_ID (line 21) | const CHART_ID = 1107320627;
constant DATA_SPREADSHEET_ID (line 22) | const DATA_SPREADSHEET_ID = '17eqFZl_WK4WVixX8PjvjfLD77DraoFwMDXeiHB3dvuM';
FILE: slides/snippets/test/test_slides_image_merging.js
constant TEMPLATE_PRESENTATION_ID (line 20) | const TEMPLATE_PRESENTATION_ID = '1MmTR712m7U_kgeweE57POWwkEyWAV17AVAWjp...
constant IMAGE_URL (line 21) | const IMAGE_URL =
constant CUSTOMER_NAME (line 23) | const CUSTOMER_NAME = 'Fake Customer';
FILE: slides/snippets/test/test_slides_refresh_sheets_chart.js
constant CHART_ID (line 21) | const CHART_ID = 1107320627;
constant DATA_SPREADSHEET_ID (line 22) | const DATA_SPREADSHEET_ID = '17eqFZl_WK4WVixX8PjvjfLD77DraoFwMDXeiHB3dvuM';
FILE: slides/snippets/test/test_slides_text_merging.js
constant TEMPLATE_PRESENTATION_ID (line 20) | const TEMPLATE_PRESENTATION_ID = '1MmTR712m7U_kgeweE57POWwkEyWAV17AVAWjp...
FILE: solutions/webhook-chat-app/index.js
function webhook (line 23) | async function webhook() {
FILE: solutions/webhook-chat-app/thread-reply.js
function webhook (line 23) | async function webhook() {
FILE: tasks/quickstart/index.js
constant SCOPES (line 25) | const SCOPES = ['https://www.googleapis.com/auth/tasks.readonly'];
constant CREDENTIALS_PATH (line 27) | const CREDENTIALS_PATH = path.join(process.cwd(), 'credentials.json');
function listTaskLists (line 32) | async function listTaskLists() {
Condensed preview — 290 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (436K chars).
[
{
"path": ".gemini/GEMINI.md",
"chars": 382,
"preview": "# Overview\n\nThis codebase is part of the Google Workspace GitHub organization, https://github.com/googleworkspace.\n\n## S"
},
{
"path": ".gemini/config.yaml",
"chars": 309,
"preview": "# Config for the Gemini Pull Request Review Bot.\n# https://github.com/marketplace/gemini-code-assist\nhave_fun: false\ncod"
},
{
"path": ".gemini/settings.json",
"chars": 161,
"preview": "{\n \"mcpServers\": {\n \"workspace-developer\": {\n \"httpUrl\": \"https://workspace-developer.goog/mcp\",\n "
},
{
"path": ".github/CODEOWNERS",
"chars": 722,
"preview": "# Copyright 2022 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this f"
},
{
"path": ".github/ISSUE_TEMPLATE.md",
"chars": 130,
"preview": "# Summary\n\nTODO\n\n## Expected Behavior\n\nSample URL:\nDescription:\n\n## Actual Behavior\n\n\n## Steps to Reproduce the Problem\n"
},
{
"path": ".github/dependabot.yml",
"chars": 386,
"preview": "version: 2\nupdates:\n - package-ecosystem: \"npm\"\n directory: \"/\"\n schedule:\n interval: \"weekly\"\n commit-me"
},
{
"path": ".github/snippet-bot.yml",
"chars": 576,
"preview": "# Copyright 2022 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this f"
},
{
"path": ".github/sync-repo-settings.yaml",
"chars": 1434,
"preview": "# Copyright 2022 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this f"
},
{
"path": ".github/workflows/automation.yml",
"chars": 2784,
"preview": "# Copyright 2022 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this f"
},
{
"path": ".github/workflows/lint.yml",
"chars": 1191,
"preview": "# Copyright 2021 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this f"
},
{
"path": ".github/workflows/test.yml",
"chars": 2105,
"preview": "# Copyright 2022 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this f"
},
{
"path": ".gitignore",
"chars": 281,
"preview": "# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n\n# Runtime data\npids\n*.pid\n*.seed\n*.lock\n\n# Dependency "
},
{
"path": ".vscode/extensions.json",
"chars": 94,
"preview": "{\n \"recommendations\": [\n \"google-workspace.google-workspace-developer-tools\"\n ]\n}"
},
{
"path": "CONTRIBUTING.md",
"chars": 1569,
"preview": "# How to become a contributor and submit your own code\n\n## Contributor License Agreements\n\nWe'd love to accept your samp"
},
{
"path": "LICENSE",
"chars": 11357,
"preview": " Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 1386,
"preview": "# Node.js samples for [Google Workspace APIs](https://developers.google.com/workspace/) docs\n\nThis repository contains N"
},
{
"path": "SECURITY.md",
"chars": 386,
"preview": "# Report a security issue\n\nTo report a security issue, please use [https://g.co/vulnz](https://g.co/vulnz). We use\n[http"
},
{
"path": "adminSDK/directory/index.js",
"chars": 1899,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "adminSDK/directory/package.json",
"chars": 533,
"preview": "{\n \"name\": \"google-admin-directory-nodejs-quickstart\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"description\": \"A sim"
},
{
"path": "adminSDK/directory/tsconfig.json",
"chars": 70,
"preview": "{\n \"extends\": \"../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "adminSDK/reports/index.js",
"chars": 2004,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "adminSDK/reports/package.json",
"chars": 531,
"preview": "{\n \"name\": \"google-admin-reports-nodejs-quickstart\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"description\": \"A simpl"
},
{
"path": "adminSDK/reports/tsconfig.json",
"chars": 70,
"preview": "{\n \"extends\": \"../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "adminSDK/reseller/index.js",
"chars": 1953,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "adminSDK/reseller/package.json",
"chars": 526,
"preview": "{\n \"name\": \"google-reseller-nodejs-quickstart\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"description\": \"A simple Nod"
},
{
"path": "adminSDK/reseller/tsconfig.json",
"chars": 70,
"preview": "{\n \"extends\": \"../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "apps-script/execute/index.js",
"chars": 2593,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "apps-script/execute/package.json",
"chars": 361,
"preview": "{\n \"name\": \"apps-script-execute\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"license\": \"Apache-2.0\",\n \"type\": \"module"
},
{
"path": "apps-script/execute/tsconfig.json",
"chars": 70,
"preview": "{\n \"extends\": \"../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "apps-script/quickstart/index.js",
"chars": 2006,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "apps-script/quickstart/package.json",
"chars": 535,
"preview": "{\n \"name\": \"google-apps-script-nodejs-quickstart\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"description\": \"A simple "
},
{
"path": "apps-script/quickstart/tsconfig.json",
"chars": 70,
"preview": "{\n \"extends\": \"../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "biome.json",
"chars": 603,
"preview": "{\n \"$schema\": \"https://biomejs.dev/schemas/2.2.4/schema.json\",\n \"vcs\": {\n \"enabled\": true,\n \"clientKind\": \"git\","
},
{
"path": "calendar/quickstart/index.js",
"chars": 2006,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "calendar/quickstart/package.json",
"chars": 529,
"preview": "{\n \"name\": \"google-calendar-nodejs-quickstart\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"description\": \"A simple Nod"
},
{
"path": "calendar/quickstart/tsconfig.json",
"chars": 70,
"preview": "{\n \"extends\": \"../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "chat/client-libraries/cloud/authentication-utils.js",
"chars": 4018,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/create-custom-emoji-user-cred.js",
"chars": 1709,
"preview": "/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/create-membership-user-cred-for-app.js",
"chars": 1606,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/create-membership-user-cred-for-group.js",
"chars": 1556,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/create-membership-user-cred.js",
"chars": 1599,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/create-message-app-cred.js",
"chars": 4024,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/create-message-user-cred-at-mention.js",
"chars": 1606,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/create-message-user-cred-message-id.js",
"chars": 1682,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/create-message-user-cred-request-id.js",
"chars": 1633,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/create-message-user-cred-thread-key.js",
"chars": 1964,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/create-message-user-cred-thread-name.js",
"chars": 2024,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/create-message-user-cred.js",
"chars": 1770,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/create-reaction-user-cred.js",
"chars": 1568,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/create-space-user-cred.js",
"chars": 1441,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/delete-custom-emoji-user-cred.js",
"chars": 1430,
"preview": "/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/delete-membership-user-cred.js",
"chars": 1451,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/delete-message-app-cred.js",
"chars": 1292,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/delete-message-user-cred.js",
"chars": 1422,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/delete-reaction-user-cred.js",
"chars": 1489,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/delete-space-user-cred.js",
"chars": 1368,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/find-dm-space-app-cred.js",
"chars": 1263,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/find-dm-space-user-cred.js",
"chars": 1400,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/get-attachment-app-cred.js",
"chars": 1348,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/get-custom-emoji-user-cred.js",
"chars": 1415,
"preview": "/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/get-membership-app-cred.js",
"chars": 1287,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/get-membership-user-cred.js",
"chars": 1429,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/get-message-app-cred.js",
"chars": 1278,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/get-message-user-cred.js",
"chars": 1417,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/get-space-app-cred.js",
"chars": 1231,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/get-space-event-user-cred.js",
"chars": 1412,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/get-space-notification-setting-user-cred.js",
"chars": 1520,
"preview": "/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/get-space-read-state-user-cred.js",
"chars": 1447,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/get-space-user-cred.js",
"chars": 1368,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/get-thread-read-state-user-cred.js",
"chars": 1499,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/list-custom-emojis-user-cred.js",
"chars": 1548,
"preview": "/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/list-memberships-app-cred.js",
"chars": 1538,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/list-memberships-user-cred.js",
"chars": 1680,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/list-messages-user-cred.js",
"chars": 1535,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/list-reactions-user-cred.js",
"chars": 1602,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/list-space-events-user-cred.js",
"chars": 1874,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/list-spaces-app-cred.js",
"chars": 1435,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/list-spaces-user-cred.js",
"chars": 1572,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/package.json",
"chars": 4285,
"preview": "{\n \"name\": \"google-chat-cloud-client-library-samples\",\n \"version\": \"0.0.1\",\n \"description\": \"Samples that use the Clo"
},
{
"path": "chat/client-libraries/cloud/set-up-space-user-cred.js",
"chars": 1636,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/tsconfig.json",
"chars": 76,
"preview": "{\n \"extends\": \"../../../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "chat/client-libraries/cloud/update-membership-user-cred.js",
"chars": 1637,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/update-message-app-cred.js",
"chars": 1880,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/update-message-user-cred.js",
"chars": 1693,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/update-space-notification-setting-user-cred.js",
"chars": 1704,
"preview": "/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/update-space-read-state-user-cred.js",
"chars": 1752,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/client-libraries/cloud/update-space-user-cred.js",
"chars": 1645,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/quickstart/index.js",
"chars": 1883,
"preview": "/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "chat/quickstart/package.json",
"chars": 528,
"preview": "{\n \"name\": \"google-chat-nodejs-quickstart\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"description\": \"A simple Node.js"
},
{
"path": "chat/quickstart/tsconfig.json",
"chars": 70,
"preview": "{\n \"extends\": \"../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "classroom/quickstart/index.js",
"chars": 1820,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "classroom/quickstart/package.json",
"chars": 531,
"preview": "{\n \"name\": \"google-classroom-nodejs-quickstart\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"description\": \"A simple No"
},
{
"path": "classroom/quickstart/tsconfig.json",
"chars": 70,
"preview": "{\n \"extends\": \"../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "docs/quickstart/index.js",
"chars": 1706,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "docs/quickstart/package.json",
"chars": 507,
"preview": "{\n \"name\": \"docs-nodejs-quickstart\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"description\": \"A simple Node.js comman"
},
{
"path": "docs/quickstart/tsconfig.json",
"chars": 70,
"preview": "{\n \"extends\": \"../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "drive/activity-v2/index.js",
"chars": 1903,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/activity-v2/package.json",
"chars": 547,
"preview": "{\n \"name\": \"google-drive-activity-v2-nodejs-quickstart\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"description\": \"A s"
},
{
"path": "drive/activity-v2/tsconfig.json",
"chars": 70,
"preview": "{\n \"extends\": \"../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "drive/quickstart/index.js",
"chars": 1798,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/quickstart/package.json",
"chars": 523,
"preview": "{\n \"name\": \"google-drive-nodejs-quickstart\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"description\": \"A simple Node.j"
},
{
"path": "drive/quickstart/tsconfig.json",
"chars": 70,
"preview": "{\n \"extends\": \"../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "drive/snippets/drive_v2/appdata_snippets/fetch_appdata_folder.js",
"chars": 1568,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v2/appdata_snippets/list_appdata.js",
"chars": 1610,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v2/appdata_snippets/package.json",
"chars": 382,
"preview": "{\n \"name\": \"drive-snippets-drive-v2-appdata-snippets\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"license\": \"Apache-2."
},
{
"path": "drive/snippets/drive_v2/appdata_snippets/tsconfig.json",
"chars": 76,
"preview": "{\n \"extends\": \"../../../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "drive/snippets/drive_v2/appdata_snippets/upload_appdata.js",
"chars": 1928,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v2/change_snippets/fetch_changes.js",
"chars": 1643,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v2/change_snippets/fetch_start_page_token.js",
"chars": 1565,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v2/change_snippets/package.json",
"chars": 381,
"preview": "{\n \"name\": \"drive-snippets-drive-v2-change-snippets\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"license\": \"Apache-2.0"
},
{
"path": "drive/snippets/drive_v2/change_snippets/tsconfig.json",
"chars": 76,
"preview": "{\n \"extends\": \"../../../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "drive/snippets/drive_v2/drive_snippets/create_drive.js",
"chars": 1786,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v2/drive_snippets/package.json",
"chars": 411,
"preview": "{\n \"name\": \"drive-snippets-drive-v2-drive-snippets\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"license\": \"Apache-2.0\""
},
{
"path": "drive/snippets/drive_v2/drive_snippets/recover_drives.js",
"chars": 2061,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v2/drive_snippets/tsconfig.json",
"chars": 76,
"preview": "{\n \"extends\": \"../../../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "drive/snippets/drive_v2/file snippets/create_folder.js",
"chars": 1668,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v2/file snippets/create_shortcut.js",
"chars": 1697,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v2/file snippets/download_file.js",
"chars": 1474,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v2/file snippets/export_pdf.js",
"chars": 1487,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v2/file snippets/move_file_to_folder.js",
"chars": 1987,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v2/file snippets/package.json",
"chars": 379,
"preview": "{\n \"name\": \"drive-snippets-drive-v2-file-snippets\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"license\": \"Apache-2.0\","
},
{
"path": "drive/snippets/drive_v2/file snippets/search_file.js",
"chars": 1729,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v2/file snippets/share_file.js",
"chars": 2358,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v2/file snippets/touch_file.js",
"chars": 1840,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v2/file snippets/tsconfig.json",
"chars": 76,
"preview": "{\n \"extends\": \"../../../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "drive/snippets/drive_v2/file snippets/upload_basic.js",
"chars": 1788,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v2/file snippets/upload_to_folder.js",
"chars": 1958,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v2/file snippets/upload_with_conversion.js",
"chars": 1990,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v3/appdata_snippets/fetch_appdata_folder.js",
"chars": 1573,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v3/appdata_snippets/list_appdata.js",
"chars": 1610,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v3/appdata_snippets/package.json",
"chars": 382,
"preview": "{\n \"name\": \"drive-snippets-drive-v3-appdata-snippets\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"license\": \"Apache-2."
},
{
"path": "drive/snippets/drive_v3/appdata_snippets/tsconfig.json",
"chars": 76,
"preview": "{\n \"extends\": \"../../../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "drive/snippets/drive_v3/appdata_snippets/upload_appdata.js",
"chars": 1896,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v3/change_snippets/fetch_changes.js",
"chars": 1867,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v3/change_snippets/fetch_start_page_token.js",
"chars": 1549,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v3/change_snippets/package.json",
"chars": 381,
"preview": "{\n \"name\": \"drive-snippets-drive-v3-change-snippets\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"license\": \"Apache-2.0"
},
{
"path": "drive/snippets/drive_v3/change_snippets/tsconfig.json",
"chars": 76,
"preview": "{\n \"extends\": \"../../../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "drive/snippets/drive_v3/drive_snippets/create_drive.js",
"chars": 1791,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v3/drive_snippets/package.json",
"chars": 411,
"preview": "{\n \"name\": \"drive-snippets-drive-v3-drive-snippets\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"license\": \"Apache-2.0\""
},
{
"path": "drive/snippets/drive_v3/drive_snippets/recover_drives.js",
"chars": 2203,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v3/drive_snippets/tsconfig.json",
"chars": 76,
"preview": "{\n \"extends\": \"../../../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "drive/snippets/drive_v3/file_snippets/create_folder.js",
"chars": 1617,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v3/file_snippets/create_shortcut.js",
"chars": 1631,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v3/file_snippets/download_file.js",
"chars": 1479,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v3/file_snippets/export_pdf.js",
"chars": 1495,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v3/file_snippets/move_file_to_folder.js",
"chars": 1958,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v3/file_snippets/package.json",
"chars": 379,
"preview": "{\n \"name\": \"drive-snippets-drive-v3-file-snippets\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"license\": \"Apache-2.0\","
},
{
"path": "drive/snippets/drive_v3/file_snippets/search_file.js",
"chars": 1593,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v3/file_snippets/share_file.js",
"chars": 2310,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v3/file_snippets/touch_file.js",
"chars": 1818,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v3/file_snippets/tsconfig.json",
"chars": 76,
"preview": "{\n \"extends\": \"../../../../tsconfig.base.json\",\n \"include\": [\"**/*.js\"]\n}\n"
},
{
"path": "drive/snippets/drive_v3/file_snippets/upload_basic.js",
"chars": 1726,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v3/file_snippets/upload_to_folder.js",
"chars": 1932,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/drive_v3/file_snippets/upload_with_conversion.js",
"chars": 1940,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/files/config.json",
"chars": 19,
"preview": "{\n \"foo\": \"bar\"\n}\n"
},
{
"path": "drive/snippets/files/document.txt",
"chars": 13,
"preview": "Hello world.\n"
},
{
"path": "drive/snippets/files/report.csv",
"chars": 59,
"preview": "\"Name\", \"Phone Number\"\n\"Bob\", \"123-4567\"\n\"Mary\", \"234-5678\""
},
{
"path": "drive/snippets/test/helpers.js",
"chars": 2748,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v2_create_drive.js",
"chars": 1183,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v2_create_folder.js",
"chars": 1021,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v2_create_shortcut.js",
"chars": 1029,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v2_download_file.js",
"chars": 1053,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v2_export_pdf.js",
"chars": 1051,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v2_fetch_appdata_folder.js",
"chars": 1016,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v2_fetch_changes.js",
"chars": 1222,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v2_fetch_start_page_token.js",
"chars": 1026,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v2_list_appdata.js",
"chars": 1172,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v2_move_file_to_folder.js",
"chars": 1249,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v2_recover_drives.js",
"chars": 1834,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v2_search_file.js",
"chars": 1074,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v2_share_file.js",
"chars": 1160,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v2_touch_file.js",
"chars": 1156,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v2_upload_appdata.js",
"chars": 1047,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v2_upload_basic.js",
"chars": 1082,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v2_upload_to_folder.js",
"chars": 1271,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v2_upload_with_conversion.js",
"chars": 1127,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v3_create_drive.js",
"chars": 1130,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v3_create_folder.js",
"chars": 1021,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v3_create_shortcut.js",
"chars": 1029,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v3_download_file.js",
"chars": 1098,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v3_export_pdf.js",
"chars": 1096,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v3_fetch_appdata_folder.js",
"chars": 1016,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v3_fetch_changes.js",
"chars": 1222,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v3_fetch_start_page_token.js",
"chars": 1026,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v3_list_appdata.js",
"chars": 1167,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v3_move_file_to_folder.js",
"chars": 1294,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v3_recover_drives.js",
"chars": 1815,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v3_search_file.js",
"chars": 1069,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v3_share_file.js",
"chars": 1160,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v3_touch_file.js",
"chars": 1156,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v3_upload_appdata.js",
"chars": 1047,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v3_upload_basic.js",
"chars": 1082,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v3_upload_to_folder.js",
"chars": 1271,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "drive/snippets/test/test_drive_v3_upload_with_conversion.js",
"chars": 1126,
"preview": "/**\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not us"
},
{
"path": "forms/snippets/add_item.js",
"chars": 2413,
"preview": "// Copyright 2022 Google LLC\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this "
},
{
"path": "forms/snippets/add_responder.js",
"chars": 2041,
"preview": "// Copyright 2025 Google LLC\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this "
},
{
"path": "forms/snippets/anyone_with_link_responder.js",
"chars": 5956,
"preview": "// Copyright 2025 Google LLC\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this "
},
{
"path": "forms/snippets/convert_form.js",
"chars": 2260,
"preview": "// Copyright 2022 Google LLC\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this "
},
{
"path": "forms/snippets/create_form.js",
"chars": 1497,
"preview": "// Copyright 2022 Google LLC\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this "
},
{
"path": "forms/snippets/create_watch.js",
"chars": 1891,
"preview": "// Copyright 2022 Google LLC\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this "
}
]
// ... and 90 more files (download for full content)
About this extraction
This page contains the full source code of the googleworkspace/node-samples GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 290 files (389.7 KB), approximately 101.1k tokens, and a symbol index with 274 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.