Xác nhận rằng bạn đang bật Meet REST API trong dự án Cloud chính xác, sau đó nhấp vào Tiếp theo.
Xác nhận rằng bạn đang bật Meet REST API, sau đó nhấp vào Bật.
gcloud CLI
Nếu cần, hãy đặt dự án hiện tại trên Google Cloud thành dự án mà bạn đã tạo:
gcloudconfigsetprojectPROJECT_ID
Thay PROJECT_ID bằng Mã dự án của dự án trên Cloud mà bạn đã tạo.
Bật Meet REST API:
gcloudservicesenablemeet.googleapis.com
Tạo mã thông báo OAuth
Để kết nối với Meet Media API, ứng dụng của bạn phải sử dụng OAuth để tạo mã truy cập. Để tìm hiểu thêm về cách truy cập vào các API của Google bằng OAuth, hãy xem bài viết Sử dụng OAuth 2.0 để truy cập vào các API của Google.
Khi tạo một ứng dụng web, bạn có thể tạo mã thông báo OAuth bằng cách sử dụng quy trình cấp ngầm. Mẫu TypeScript này sử dụng quy trình này để tạo mã thông báo OAuth.
Thêm URL của ứng dụng đã triển khai vào Authorized JavaScript Origins (Nguồn gốc JavaScript được phép) và Authorized Redirect URIs (URI chuyển hướng được phép).
Sao chép mã nhận dạng ứng dụng và dán mã này vào trang web đã triển khai.
Nhấn vào nút đăng nhập rồi làm theo lời nhắc. Nếu bạn gặp lỗi, hãy lưu ý rằng có thể mất vài phút để URI chuyển hướng có hiệu lực.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-29 UTC."],[],[],null,["# Meet Media API: TypeScript reference client quickstart\n\n| **Developer Preview:** Available as part of the [Google Workspace Developer Preview Program](https://developers.google.com/workspace/preview), which grants early access to certain features. \n|\n| **To use the Meet Media API to access real-time media from a conference, the Google Cloud project, OAuth principal, and all participants in the conference must be enrolled in the Developer Preview Program.**\n\nThis page explains how to set up and run a sample using the [TypeScript\nreference client\nimplementation](https://github.com/googleworkspace/meet-media-api-samples). To\nlearn about the C++ client instead, see the [C++ reference client\nquickstart](/workspace/meet/media-api/guides/cpp).\n\nPrerequisites\n-------------\n\nTo run this quickstart, you need the following prerequisites:\n\n- You've cloned the [GitHub\n repository](https://github.com/googleworkspace/meet-media-api-samples).\n- [Webpack](https://webpack.js.org/).\n- [Node.js](https://nodejs.org).\n- [Yarn](https://classic.yarnpkg.com/lang/en/docs/install).\n- [`gcloud`](https://cloud.google.com/sdk/docs/install-sdk) CLI.\n- [A Google Cloud project](/workspace/guides/create-project) with Google Meet REST API enabled.\n- A Google Workspace account.\n- Use a Chrome browser with version \\\u003e= 94.\n\n### Enable the Meet REST API\n\nBefore using Google APIs, you need to turn them on in a Google Cloud project. You can turn on one or more APIs in a single Google Cloud project. \n\n### Google Cloud console\n\n1. In the Google Cloud console, enable the Meet REST API.\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=meet.googleapis.com)\n2. Confirm that you're enabling the Meet REST API in the correct\n Cloud project, then click **Next**.\n\n3. Confirm that you're enabling the Meet REST API, then click\n **Enable**.\n\n### gcloud CLI\n\n1. If necessary, set the current Cloud project to the one you\n created:\n\n gcloud config set project \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with the **Project ID** of the\n Cloud project you created.\n2. Enable the Meet REST API:\n\n gcloud services enable meet.googleapis.com\n\nGenerate OAuth tokens\n---------------------\n\nTo connect to the Meet Media API, your app must use OAuth to generate\naccess tokens. To learn more about accessing Google APIs with OAuth, see [*Using\nOAuth 2.0 to Access Google APIs*](/identity/protocols/oauth2).\n\nWhen building a web app, you can generate OAuth tokens using the [implicit grant\nflow](/identity/protocols/oauth2/javascript-implicit-flow). This TypeScript\nsample uses this flow to generate OAuth tokens.\n\nRun the sample\n--------------\n\n| **Note:** Due to CORS requirements, you must deploy this sample for it to call the Meet REST API. `localhost` won't work. We recommend deploying the sample to [*Google App Engine*](https://cloud.google.com/appengine).\n\n1. [Create an OAuth client](/identity/protocols/oauth2/javascript-implicit-flow#prerequisites)\n\n2. Within the `web/samples` directory, build the sample:\n\n $ yarn install --frozen-lockfile\n $ webpack\n\n3. Follow the\n [*Authenticate for using the gcloud CLI*](https://cloud.google.com/docs/authentication/gcloud)\n guide to sign in and select your Google Cloud project.\n\n4. Deploy your server to [*Google App Engine*](https://cloud.google.com/appengine).\n\n $ gcloud app deploy app.yaml\n\n5. Navigate to your endpoint:\n\n $ gcloud app browse\n\n6. Follow the [*Create access credentials*](/workspace/guides/create-credentials#oauth-client-id)\n guide to create OAuth 2.0 credentials with these scopes:\n\n - `https://www.googleapis.com/auth/meetings.conference.media.readonly`\n - `https://www.googleapis.com/auth/meetings.space.readonly`\n\n Add your deployed app's URL to *Authorized JavaScript Origins* and\n *Authorized Redirect URIs*.\n7. Copy the client ID and paste it into the deployed web page.\n\n8. Tap the sign-in button and follow the prompts. If you run into an error,\n note that it might take a few minutes for the redirect URIs to propagate.\n\n9. [Create and join a meeting](https://meet.google.com/new). Copy the meeting\n code, pasting it into the \"meeting code\" input on the page.\n\n10. Select the number of video streams and enable audio.\n\n11. Click *Create Client* , then *Join Meeting*.\n\n12. Observe the video and audio streams.\n\nRelated topics\n--------------\n\n- [Troubleshoot and fix Meet Media API errors](/workspace/meet/media-api/guides/troubleshoot)\n\n- [Meet Media API data channels reference](/workspace/meet/media-api/reference/dc/media_api)"]]