Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

integrations: Add Google Meet video call integration.

0xthedance6695fd9746cd
diff --git a/api_docs/changelog.md b/api_docs/changelog.md
index 60dfc251b97..aa38a9e72c2 100644
--- a/api_docs/changelog.md
+++ b/api_docs/changelog.md
@@ -20,6 +20,25 @@ format used by the Zulip server that they are interacting with.
## Changes in Zulip 13.0
+**Feature level 514**
+
+* [`POST /register`](/api/register-queue), [`GET /events`](/api/get-events),
+ `PATCH /realm`: Google Meet OAuth integration added as an option
+ for the realm setting `video_chat_provider`.
+* [`POST /calls/google_meet/create`](/api/create-google-meet-video-call): Added
+ a new endpoint to create a Google Meet video call URL.
+* [`POST /register`](/api/register-queue): Added `has_google_meet_token`
+ boolean field to response.
+* [`GET /events`](/api/get-events): A `has_google_meet_token` event is sent
+ to clients when the user has completed the OAuth flow for the Google Meet
+ video call integration.
+* [`POST /register`](/api/register-queue): Added
+ `server_google_meet_app_internal` boolean field to the response, indicating
+ whether the server has a Google Cloud OAuth app configured with an internal,
+ workspace-restricted, audience. Clients should use this to warn users that
+ the video call feature is restricted to a particular Google Workspace before
+ starting the Google OAuth flow for the Google Meet video call integration.
+
**Feature level 513**
* [`POST /messages/render`](/api/render-message): Added the
diff --git a/api_docs/include/rest-endpoints.md b/api_docs/include/rest-endpoints.md
index 1efa056d238..1a69d6bbaea 100644
--- a/api_docs/include/rest-endpoints.md
+++ b/api_docs/include/rest-endpoints.md
@@ -182,6 +182,7 @@
* [Create BigBlueButton video call](/api/create-big-blue-button-video-call)
* [Create Constructor Groups video call](/api/create-constructor-groups-video-call)
+* [Create Google Meet video call](/api/create-google-meet-video-call)
* [Create Nextcloud Talk video call](/api/create-nextcloud-talk-video-call)
* [Create Webex video call](/api/create-webex-video-call)
diff --git a/docs/production/video-calls.md b/docs/production/video-calls.md
index c74399ea8fb..d1bc6c56a33 100644
--- a/docs/production/video-calls.md
+++ b/docs/production/video-calls.md
@@ -12,6 +12,7 @@ supported by Zulip are:
- [Constructor Groups](https://zulip.com/integrations/constructor-groups)
- [Nextcloud Talk](https://zulip.com/integrations/nextcloud-talk)
- [Webex](https://zulip.com/integrations/webex)
+- [Google Meet](https://zulip.com/integrations/category/video-calling)
By default, Zulip uses the [cloud version of Jitsi Meet](https://meet.jit.si/)
as its call provider. This page documents the configurations required to support
@@ -240,3 +241,68 @@ Webex organizations, a personal room meeting is created in Webex.
This enables Webex support in your Zulip server. Finally, [configure Webex
as the video call provider](https://zulip.com/help/configure-call-provider)
in the Zulip organization where you want to use it.
+
+## Google Meet
+
+To use the [Google Meet](https://meet.google.com/) integration on a
+self-hosted Zulip installation, you'll need to create a Google Cloud
+OAuth 2.0 app with access to the Google Meet REST API.
+
+:::{note}
+There are two Audience types for Google Cloud OAuth 2.0 apps:
+
+- **Internal**: Zulip users must have an account in the Google
+ Workspace organization associated with your Google Cloud OAuth app
+ in order to create calls.
+- **External**: Zulip users just need a regular Google account to
+ create calls, but your Google Cloud OAuth app must go through
+ [Google's OAuth verification](https://support.google.com/cloud/answer/13463073?hl=en&ref_topic=13460882&sjid=6878633552635075588-EU)
+ process.
+ :::
+
+### Create a Google Cloud OAuth 2.0 app
+
+1. Visit the [Google Cloud Console](https://console.cloud.google.com/) and
+ create or select a project.
+
+1. Enable the **Google Meet REST API** for your project under **APIs & Services >
+ Library**.
+
+1. Configure the **OAuth consent screen** under **APIs & Services > OAuth
+ consent screen**:
+
+ - Fill in the **App name** and **User support email**.
+ - Choose the audience type as described above.
+ - Add **Developer contact information**.
+
+1. If creating an app for use outside of your Google Workspace
+ organization, click **Data Access > Add or Remove Scopes** and add the
+ `https://www.googleapis.com/auth/meetings.space.created` scope.
+
+1. Under **APIs & Services > Credentials**, click **Create Credentials** and
+ select **OAuth client ID**.
+
+ - Choose **Web application** as the application type.
+ - Under **Authorized redirect URIs**, add
+ `https://zulip.example.com/calls/google_meet/complete`, replacing
+ `zulip.example.com` with your Zulip organization's URL.
+ - Note the **Client ID** and **Client Secret** shown after creation.
+
+### Configure your Zulip server
+
+1. In `/etc/zulip/zulip-secrets.conf`, set `video_google_meet_client_secret`
+ to the **Client Secret** you noted down for your Google Cloud OAuth client.
+
+1. In `/etc/zulip/settings.py`, set `VIDEO_GOOGLE_MEET_CLIENT_ID` to the
+ **Client ID** you noted down for your Google Cloud OAuth client.
+
+1. Set `VIDEO_GOOGLE_MEET_AUDIENCE_INTERNAL` in `/etc/zulip/settings.py` to
+ reflect whether your Google Cloud OAuth client is configured for an
+ internal audience, as described above.
+
+1. Restart the Zulip server with
+ `/home/zulip/deployments/current/scripts/restart-server`.
+
+This enables Google Meet support in your Zulip server. Finally,
+[configure Google Meet as the video call provider](https://zulip.com/help/configure-call-provider)
+in the Zulip organization where you want to use it.
diff --git a/starlight_help/src/content/docs/configure-call-provider.mdx b/starlight_help/src/content/docs/configure-call-provider.mdx
index 3fae512da64..c5f60f07c0a 100644
--- a/starlight_help/src/content/docs/configure-call-provider.mdx
+++ b/starlight_help/src/content/docs/configure-call-provider.mdx
@@ -20,6 +20,7 @@ supported by Zulip are:
* [Zoom integration](/integrations/zoom)
* [BigBlueButton integration](/integrations/big-blue-button)
* [Constructor Groups integration](/integrations/constructor-groups)
+* [Google Meet integration](/integrations/google-meet)
* [Nextcloud Talk integration](/integrations/nextcloud-talk)
* [Webex integration](/integrations/webex)
@@ -62,5 +63,6 @@ instance of Jitsi Meet.
* [Zoom integration](/integrations/zoom)
* [BigBlueButton integration](/integrations/big-blue-button)
* [Constructor Groups integration](/integrations/constructor-groups)
+* [Google Meet integration](/integrations/google-meet)
* [Nextcloud Talk integration](/integrations/nextcloud-talk)
* [Webex integration](/integrations/webex)
diff --git a/static/images/integrations/bot_avatars/google-meet.png b/static/images/integrations/bot_avatars/google-meet.png
new file mode 100644
index 00000000000..bfb614158b0
Binary files /dev/null and b/static/images/integrations/bot_avatars/google-meet.png differ
diff --git a/static/images/integrations/logos/google-meet.svg b/static/images/integrations/logos/google-meet.svg
new file mode 100644
index 00000000000..70822071443
--- /dev/null
+++ b/static/images/integrations/logos/google-meet.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="176" height="138" fill="none" viewBox="0 0 176 138"><path fill="url(#a)" d="M102.015 81.88c-6.829-4.718-6.921-14.778-.179-19.62L157 22.643c7.94-5.701 19-.038 19 9.737v77.755c0 9.675-10.861 15.359-18.821 9.859z" style="fill:url(#a)"/><path fill="url(#b)" d="M0 44C0 19.7 19.7 0 44 0h64c11.046 0 20 8.954 20 20v98c0 11.046-8.954 20-20 20H20c-11.046 0-20-8.954-20-20Z" style="fill:url(#b)"/><mask id="d" width="129" height="138" x="8" y="27" maskUnits="userSpaceOnUse"><path fill="#fff" d="M8 71c0-24.3 19.7-44 44-44h64c11.046 0 20 8.954 20 20v98c0 11.046-8.954 20-20 20H28c-11.046 0-20-8.954-20-20Z"/></mask><g filter="url(#c)" mask="url(#d)" transform="translate(-8 -27)"><path fill="url(#f)" d="m73.906 99.198 110-63.198v124z" style="fill:url(#f)"/></g><circle cx="30" cy="108" r="14" fill="#fff"/><defs><linearGradient id="a" x1="128.8" x2="227.2" y1="104.44" y2="104.44" gradientTransform="translate(-8 -27)" gradientUnits="userSpaceOnUse"><stop stop-color="#f6a100"/><stop offset="1" stop-color="#ffbe00"/></linearGradient><linearGradient id="f" x1="136.22" x2="78.5" y1="91.32" y2="91.19" gradientUnits="userSpaceOnUse"><stop offset=".15" stop-color="#ffb5e8"/><stop offset="1" stop-color="#ffdbf5" stop-opacity="0"/></linearGradient><radialGradient id="b" cx="0" cy="0" r="1" gradientTransform="matrix(-159.725 0 0 -135.852 152.325 69)" gradientUnits="userSpaceOnUse"><stop offset=".15" stop-color="#ffe921"/><stop offset="1" stop-color="#fec700"/></radialGradient><filter id="c" width="166" height="180" x="45.91" y="8" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_37584_9338" stdDeviation="14"/></filter></defs></svg>
\ No newline at end of file
diff --git a/templates/zerver/integrations/big-blue-button.md b/templates/zerver/integrations/big-blue-button.md
index fea9ff591c3..22d65d2bb5d 100644
--- a/templates/zerver/integrations/big-blue-button.md
+++ b/templates/zerver/integrations/big-blue-button.md
@@ -48,5 +48,6 @@ as your call provider instead.
- [Zoom integration](/integrations/zoom)
- [Constructor Groups integration](/integrations/constructor-groups)
* [BigBlueButton server configuration](https://docs.bigbluebutton.org/administration/customize/#other-configuration-changes)
+- [Google Meet integration](/integrations/google-meet)
- [Nextcloud Talk integration](/integrations/nextcloud-talk)
- [Webex integration](/integrations/webex)
diff --git a/templates/zerver/integrations/constructor-groups.md b/templates/zerver/integrations/constructor-groups.md
index 5374b8b2945..86aaed51851 100644
--- a/templates/zerver/integrations/constructor-groups.md
+++ b/templates/zerver/integrations/constructor-groups.md
@@ -52,6 +52,7 @@ source video conferencing solution. You can configure Zulip to use
- [Jitsi Meet integration](/integrations/jitsi)
- [Zoom integration](/integrations/zoom)
- [BigBlueButton integration](/integrations/big-blue-button)
+- [Google Meet integration](/integrations/google-meet)
- [Nextcloud Talk integration](/integrations/nextcloud-talk)
- [Webex integration](/integrations/webex)
diff --git a/templates/zerver/integrations/google-meet.md b/templates/zerver/integrations/google-meet.md
new file mode 100644
index 00000000000..6025e3dc138
--- /dev/null
+++ b/templates/zerver/integrations/google-meet.md
@@ -0,0 +1,100 @@
+# Use Google Meet as your call provider in Zulip
+
+You can configure Google Meet as the call provider for your organization. Users
+will be able to start a Google Meet and invite others using the **add video
+call** (<i class="zulip-icon zulip-icon-video-call"></i>) button [in the
+compose box](/help/start-a-call).
+
+!!! warn ""
+
+ **Note:** This is currently only possible on self-hosted Zulip
+ installations.
+
+## Configure Google Meet as your call provider
+
+By default, Zulip integrates with
+[Jitsi Meet](https://jitsi.org/jitsi-meet/), a fully-encrypted, 100% open
+source video conferencing solution. You can configure Zulip to use Google Meet
+as your call provider instead.
+
+### Create a Google Cloud OAuth 2.0 app
+
+You need to create a Google Cloud OAuth 2.0 app with access to the Google
+Meet REST API.
+
+!!! warn ""
+
+ **Note:** There are two Audience types for Google Cloud OAuth 2.0 apps:
+
+ - **Internal**: Zulip users must have an account in the Google
+ Workspace organization associated with your Google Cloud OAuth app
+ in order to create calls.
+ - **External**: Zulip users just need a regular Google account to
+ create calls, but your Google Cloud OAuth app must go through
+ [Google's OAuth verification](https://support.google.com/cloud/answer/13463073?hl=en&ref_topic=13460882&sjid=6878633552635075588-EU)
+ process.
+
+{start_tabs}
+
+1. Visit the [Google Cloud Console](https://console.cloud.google.com/) and
+ create or select a project.
+
+1. Enable the **Google Meet REST API** for your project under **APIs & Services >
+ Library**.
+
+1. Configure the **OAuth consent screen** under **APIs & Services > OAuth
+ consent screen**:
+ - Fill in the **App name** and **User support email**.
+ - Choose the audience type as described above.
+ - Add **Developer contact information**.
+
+1. If creating an app for use outside of your Google Workspace organization,
+ click **Data Access > Add or Remove Scopes** and add the
+ `https://www.googleapis.com/auth/meetings.space.created` scope.
+
+1. Under **APIs & Services > Credentials**, click **Create Credentials** and
+ select **OAuth client ID**.
+ - Choose **Web application** as the application type.
+ - Under **Authorized redirect URIs**, add
+ `https://zulip.example.com/calls/google_meet/complete`, replacing
+ `zulip.example.com` with your Zulip organization's URL.
+ - Note the **Client ID** and **Client Secret** shown after creation.
+
+{end_tabs}
+
+### Configure your Zulip server and organization
+
+{start_tabs}
+
+1. In `/etc/zulip/zulip-secrets.conf`, set `video_google_meet_client_secret`
+ to the **Client Secret** you noted down for your Google Cloud OAuth client.
+
+1. In `/etc/zulip/settings.py`, set `VIDEO_GOOGLE_MEET_CLIENT_ID` to the
+ **Client ID** you noted down for your Google Cloud OAuth client.
+
+1. Set `VIDEO_GOOGLE_MEET_AUDIENCE_INTERNAL` in `/etc/zulip/settings.py` to
+ reflect whether your Google Cloud OAuth client is configured for an
+ internal audience, as described above.
+
+1. Restart the Zulip server with
+ `/home/zulip/deployments/current/scripts/restart-server`.
+
+{settings_tab|organization-settings}
+
+1. Under **Compose settings**, select Google Meet from the **Call provider**
+ dropdown.
+
+1. Click **Save changes**.
+
+{end_tabs}
+
+## Related documentation
+
+- [How to start a call](/help/start-a-call)
+- [Google Meet REST API documentation](https://developers.google.com/workspace/meet/api/reference/rest)
+- [Jitsi Meet integration](/integrations/jitsi)
+- [BigBlueButton integration](/integrations/big-blue-button)
+- [Webex integration](/integrations/webex)
+- [Zoom integration](/integrations/zoom)
+- [Constructor Groups integration](/integrations/constructor-groups)
+- [Nextcloud Talk integration](/integrations/nextcloud-talk)
diff --git a/templates/zerver/integrations/jitsi.md b/templates/zerver/integrations/jitsi.md
index fd209abda14..7874dd5d8ac 100644
--- a/templates/zerver/integrations/jitsi.md
+++ b/templates/zerver/integrations/jitsi.md
@@ -33,5 +33,6 @@ instance of Jitsi Meet.
- [Zoom integration](/integrations/zoom)
- [BigBlueButton integration](/integrations/big-blue-button)
- [Constructor Groups integration](/integrations/constructor-groups)
+- [Google Meet integration](/integrations/google-meet)
- [Nextcloud Talk integration](/integrations/nextcloud-talk)
- [Webex integration](/integrations/webex)
diff --git a/templates/zerver/integrations/nextcloud-talk.md b/templates/zerver/integrations/nextcloud-talk.md
index 46696432b10..53c6495750b 100644
--- a/templates/zerver/integrations/nextcloud-talk.md
+++ b/templates/zerver/integrations/nextcloud-talk.md
@@ -63,4 +63,5 @@ Talk as your call provider instead.
- [Zoom integration](/integrations/zoom)
- [BigBlueButton integration](/integrations/big-blue-button)
- [Constructor Groups integration](/integrations/constructor-groups)
+- [Google Meet integration](/integrations/google-meet)
- [Webex integration](/integrations/webex)
diff --git a/templates/zerver/integrations/webex.md b/templates/zerver/integrations/webex.md
index 572eeced3b6..75179eba6e3 100644
--- a/templates/zerver/integrations/webex.md
+++ b/templates/zerver/integrations/webex.md
@@ -76,4 +76,5 @@ call provider instead.
- [Jitsi Meet integration](/integrations/jitsi)
- [BigBlueButton integration](/integrations/big-blue-button)
- [Constructor Groups integration](/integrations/constructor-groups)
+- [Google Meet integration](/integrations/google-meet)
- [Nextcloud Talk integration](/integrations/nextcloud-talk)
diff --git a/templates/zerver/integrations/zoom.md b/templates/zerver/integrations/zoom.md
index 90491c7becd..9d860dc2fb0 100644
--- a/templates/zerver/integrations/zoom.md
+++ b/templates/zerver/integrations/zoom.md
@@ -40,5 +40,6 @@ in order to use this integration.
- [Jitsi Meet integration](/integrations/jitsi)
- [BigBlueButton integration](/integrations/big-blue-button)
- [Constructor Groups integration](/integrations/constructor-groups)
+- [Google Meet integration](/integrations/google-meet)
- [Nextcloud Talk integration](/integrations/nextcloud-talk)
- [Webex integration](/integrations/webex)
diff --git a/tools/lib/capitalization.py b/tools/lib/capitalization.py
index b44986a28e4..7f7eccf2ebe 100644
--- a/tools/lib/capitalization.py
+++ b/tools/lib/capitalization.py
@@ -43,6 +43,8 @@ IGNORED_PHRASES = [
r"DMs",
r"Slack",
r"Google",
+ r"Google Meet",
+ r"Google Workspace",
r"Terms of Service",
r"TikTok",
r"Tuesday",
diff --git a/version.py b/version.py
index 912aad41f59..1209508b199 100644
--- a/version.py
+++ b/version.py
@@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.9.3"
# https://zulip.readthedocs.io/en/latest/documentation/api.html#step-by-step-guide
# Also available at docs/documentation/api.md.
-API_FEATURE_LEVEL = 513
+API_FEATURE_LEVEL = 514
# Bump the minor PROVISION_VERSION to indicate that folks should provision
# only when going from an old version of the code to a newer version. Bump
diff --git a/web/src/compose_call.ts b/web/src/compose_call.ts
index c45fd0e91e8..c913ff7656c 100644
--- a/web/src/compose_call.ts
+++ b/web/src/compose_call.ts
@@ -1,11 +1,13 @@
import {realm} from "./state_data.ts";
-export type OAuthCallProvider = "webex" | "zoom";
+export type OAuthCallProvider = "google_meet" | "webex" | "zoom";
export function current_oauth_call_provider(): OAuthCallProvider | null {
const available_providers = realm.realm_available_video_chat_providers;
const realm_provider = realm.realm_video_chat_provider;
switch (realm_provider) {
+ case available_providers.google_meet?.id:
+ return "google_meet";
case available_providers.webex?.id:
return "webex";
case available_providers.zoom?.id:
diff --git a/web/src/compose_call_ui.ts b/web/src/compose_call_ui.ts
index 73fadd56dab..bca64e2f9b9 100644
--- a/web/src/compose_call_ui.ts
+++ b/web/src/compose_call_ui.ts
@@ -1,6 +1,8 @@
import {$} from "jquery";
import * as z from "zod/mini";
+import render_confirm_google_meet_authorization from "../templates/confirm_dialog/confirm_google_meet_authorization.hbs";
+
import * as channel from "./channel.ts";
import * as compose_banner from "./compose_banner.ts";
import * as compose_call from "./compose_call.ts";
@@ -12,6 +14,7 @@ import {
} from "./compose_closed_ui.ts";
import * as compose_state from "./compose_state.ts";
import * as compose_ui from "./compose_ui.ts";
+import * as confirm_dialog from "./confirm_dialog.ts";
import {$t, $t_html} from "./i18n.ts";
import * as message_store from "./message_store.ts";
import * as people from "./people.ts";
@@ -145,6 +148,9 @@ export function generate_and_insert_audio_or_video_call_link(
parsed.data.code === "INVALID_VIDEO_CALL_PROVIDER_TOKEN"
) {
switch (oauth_call_provider) {
+ case "google_meet":
+ current_user.has_google_meet_token = false;
+ break;
case "webex":
current_user.has_webex_token = false;
break;
@@ -179,13 +185,7 @@ export function generate_and_insert_audio_or_video_call_link(
}
};
- if (
- (current_user.has_webex_token && oauth_call_provider === "webex") ||
- ((current_user.has_zoom_token || provider_is_zoom_server_to_server) &&
- oauth_call_provider === "zoom")
- ) {
- make_oauth_call();
- } else {
+ const open_oauth_popup = (): void => {
compose_call_session.add_oauth_token_callback(oauth_call_provider, () => {
make_oauth_call(true);
});
@@ -197,6 +197,26 @@ export function generate_and_insert_audio_or_video_call_link(
"_blank",
"width=800,height=500,noopener,noreferrer",
);
+ };
+
+ if (
+ (current_user.has_google_meet_token && oauth_call_provider === "google_meet") ||
+ (current_user.has_webex_token && oauth_call_provider === "webex") ||
+ ((current_user.has_zoom_token || provider_is_zoom_server_to_server) &&
+ oauth_call_provider === "zoom")
+ ) {
+ make_oauth_call();
+ } else if (oauth_call_provider === "google_meet" && realm.server_google_meet_app_internal) {
+ confirm_dialog.launch({
+ modal_title_html: $t_html({defaultMessage: "Continue with Google?"}),
+ modal_content_html: render_confirm_google_meet_authorization(),
+ modal_submit_button_text: $t({defaultMessage: "Continue"}),
+ help_link: "/integrations/google-meet",
+ is_compact: true,
+ on_click: open_oauth_popup,
+ });
+ } else {
+ open_oauth_popup();
}
} else {
switch (realm.realm_video_chat_provider) {
diff --git a/web/src/server_events_dispatch.js b/web/src/server_events_dispatch.js
index 2e2b508164d..65acfc2f648 100644
--- a/web/src/server_events_dispatch.js
+++ b/web/src/server_events_dispatch.js
@@ -224,6 +224,13 @@ export function dispatch_normal_event(event) {
break;
}
+ case "has_google_meet_token":
+ current_user.has_google_meet_token = event.value;
+ if (event.value) {
+ compose_call_session_manager.run_and_clear_callbacks_for_provider("google_meet");
+ }
+ break;
+
case "has_webex_token":
current_user.has_webex_token = event.value;
if (event.value) {
diff --git a/web/src/state_data.ts b/web/src/state_data.ts
index 3abf2c4b304..f40508ea7a1 100644
--- a/web/src/state_data.ts
+++ b/web/src/state_data.ts
@@ -391,6 +391,7 @@ const current_user_schema = z.object({
delivery_email: z.string(),
email: z.string(),
full_name: z.string(),
+ has_google_meet_token: z.boolean(),
has_webex_token: z.boolean(),
has_zoom_token: z.boolean(),
is_admin: z.boolean(),
@@ -482,6 +483,7 @@ export const realm_schema = z.object({
constructor_groups: z.optional(z.object({name: z.string(), id: z.number()})),
nextcloud_talk: z.optional(z.object({name: z.string(), id: z.number()})),
webex: z.optional(z.object({name: z.string(), id: z.number()})),
+ google_meet: z.optional(z.object({name: z.string(), id: z.number()})),
}),
realm_avatar_changes_disabled: z.boolean(),
realm_bot_domain: z.string(),
@@ -615,6 +617,7 @@ export const realm_schema = z.object({
server_avatar_changes_disabled: z.boolean(),
server_can_summarize_topics: z.boolean(),
server_emoji_data_url: z.string(),
+ server_google_meet_app_internal: z.boolean(),
server_inline_image_preview: z.boolean(),
server_inline_url_embed_preview: z.boolean(),
server_max_deactivated_realm_deletion_days: z.nullable(z.number()),
diff --git a/web/templates/confirm_dialog/confirm_google_meet_authorization.hbs b/web/templates/confirm_dialog/confirm_google_meet_authorization.hbs
new file mode 100644
index 00000000000..fabd8005c84
--- /dev/null
+++ b/web/templates/confirm_dialog/confirm_google_meet_authorization.hbs
@@ -0,0 +1,6 @@
+<p>
+ {{t "In this organization, creating Google Meet calls is restricted to accounts in its Google Workspace."}}
+</p>
+<p>
+ {{t "Continue to sign in with your Google Workspace account, if you have one. Otherwise, cancel and contact your Google Workspace administrator."}}
+</p>
diff --git a/web/tests/compose_call.test.cjs b/web/tests/compose_call.test.cjs
index 2a8f29beb58..e6d969ffe34 100644
--- a/web/tests/compose_call.test.cjs
+++ b/web/tests/compose_call.test.cjs
@@ -84,6 +84,10 @@ const realm_available_video_chat_providers = {
id: 8,
name: "Webex",
},
+ google_meet: {
+ id: 9,
+ name: "Google Meet",
+ },
};
function test(label, f) {
@@ -305,6 +309,66 @@ test("videos", ({override, override_rewire}) => {
assert.match(syntax_to_insert, video_link_regex);
})();
+ (function test_google_meet_video_link_compose_clicked() {
+ let syntax_to_insert;
+ let called = false;
+
+ const $textarea = $.create("google-meet-target-stub");
+ $textarea.set_parents_result(".message_edit_form", []);
+
+ const ev = {
+ preventDefault() {},
+ stopPropagation() {},
+ };
+
+ override(compose_ui, "insert_syntax_and_focus", (syntax) => {
+ syntax_to_insert = syntax;
+ called = true;
+ success_callback = undefined;
+ });
+
+ override(
+ realm,
+ "realm_video_chat_provider",
+ realm_available_video_chat_providers.google_meet.id,
+ );
+ override(current_user, "has_google_meet_token", false);
+
+ window.open = (url) => {
+ assert.ok(url.endsWith("/calls/google_meet/register"));
+
+ // The event here has value=true. We keep it in events.js to
+ // allow our tooling to verify its schema.
+ server_events_dispatch.dispatch_normal_event(events.fixtures.has_google_meet_token);
+ };
+
+ let success_callback;
+ const xhr_object = {abort() {}};
+ channel.post = (payload) => {
+ assert.equal(payload.url, "/json/calls/google_meet/create");
+ success_callback = payload.success;
+ return xhr_object;
+ };
+
+ function call_success_callback() {
+ assert.ok(success_callback !== undefined);
+ success_callback({
+ result: "success",
+ msg: "",
+ url: "https://meet.google.com/abc-mnop-xyz",
+ });
+ }
+
+ $("textarea#compose-textarea").val("");
+ const video_handler = $("body").get_on_handler("click", ".video_link");
+ video_handler.call($textarea, ev);
+ call_success_callback();
+ const video_link_regex =
+ /\[translated: Join video call\.]\(https:\/\/meet\.google\.com\/abc-mnop-xyz\)/;
+ assert.ok(called);
+ assert.match(syntax_to_insert, video_link_regex);
+ })();
+
(function test_bbb_audio_and_video_links_compose_clicked() {
let syntax_to_insert;
let called = false;
diff --git a/web/tests/lib/events.cjs b/web/tests/lib/events.cjs
index c44f0a66655..cf6abb7ebec 100644
--- a/web/tests/lib/events.cjs
+++ b/web/tests/lib/events.cjs
@@ -255,6 +255,11 @@ exports.fixtures = {
topic: "topic1",
},
+ has_google_meet_token: {
+ type: "has_google_meet_token",
+ value: true,
+ },
+
has_webex_token: {
type: "has_webex_token",
value: true,
diff --git a/zerver/actions/video_calls.py b/zerver/actions/video_calls.py
index 5ee3a727682..cf2d1c3510d 100644
--- a/zerver/actions/video_calls.py
+++ b/zerver/actions/video_calls.py
@@ -2,20 +2,30 @@ from typing import Literal
from django.db import transaction
-from zerver.lib.event_types import BaseEvent, HasWebexTokenEvent, HasZoomTokenEvent
+from zerver.lib.event_types import (
+ BaseEvent,
+ HasGoogleMeetTokenEvent,
+ HasWebexTokenEvent,
+ HasZoomTokenEvent,
+)
from zerver.models import UserProfile
from zerver.tornado.django_api import send_event_on_commit
@transaction.atomic(durable=True)
def do_set_video_call_provider_token(
- user: UserProfile, token_key: Literal["zoom", "webex"], /, token: dict[str, object] | None
+ user: UserProfile,
+ token_key: Literal["google_meet", "webex", "zoom"],
+ /,
+ token: dict[str, object] | None,
) -> None:
user.third_party_api_state[token_key] = token
user.save(update_fields=["third_party_api_state"])
event: BaseEvent
- if token_key == "zoom":
- event = HasZoomTokenEvent(value=token is not None)
- else:
+ if token_key == "google_meet":
+ event = HasGoogleMeetTokenEvent(value=token is not None)
+ elif token_key == "webex":
event = HasWebexTokenEvent(value=token is not None)
+ else:
+ event = HasZoomTokenEvent(value=token is not None)
send_event_on_commit(user.realm, event, [user.id])
diff --git a/zerver/lib/event_schema.py b/zerver/lib/event_schema.py
index b52f968d14c..53b21b141cd 100644
--- a/zerver/lib/event_schema.py
+++ b/zerver/lib/event_schema.py
@@ -35,6 +35,7 @@ from zerver.lib.event_types import (
DraftsAddEvent,
DraftsRemoveEvent,
DraftsUpdateEvent,
+ HasGoogleMeetTokenEvent,
HasWebexTokenEvent,
HasZoomTokenEvent,
HeartbeatEvent,
@@ -248,6 +249,7 @@ check_web_reload_client_event = make_checker(WebReloadClientEvent)
_check_channel_folder_update = make_checker(ChannelFolderUpdateEvent)
_check_delete_message = make_checker(DeleteMessageEvent)
+_check_has_google_meet_token = make_checker(HasGoogleMeetTokenEvent)
_check_has_webex_token = make_checker(HasWebexTokenEvent)
_check_has_zoom_token = make_checker(HasZoomTokenEvent)
_check_legacy_presence = make_checker(LegacyPresenceEvent)
@@ -321,6 +323,15 @@ def check_delete_message(
assert set(event.keys()) == keys
+def check_has_google_meet_token(
+ var_name: str,
+ event: dict[str, object],
+ value: bool,
+) -> None:
+ _check_has_google_meet_token(var_name, event)
+ assert event["value"] == value
+
+
def check_has_webex_token(
var_name: str,
event: dict[str, object],
diff --git a/zerver/lib/event_types.py b/zerver/lib/event_types.py
index 8766b921147..24bd45d34be 100644
--- a/zerver/lib/event_types.py
+++ b/zerver/lib/event_types.py
@@ -231,6 +231,11 @@ class DraftsUpdateEvent(BaseEvent):
draft: DraftFields
+class HasGoogleMeetTokenEvent(BaseEvent):
+ type: Literal["has_google_meet_token"] = "has_google_meet_token"
+ value: bool
+
+
class HasWebexTokenEvent(BaseEvent):
type: Literal["has_webex_token"] = "has_webex_token"
value: bool
diff --git a/zerver/lib/events.py b/zerver/lib/events.py
index 1c29c3fd896..f3869d2025c 100644
--- a/zerver/lib/events.py
+++ b/zerver/lib/events.py
@@ -579,6 +579,8 @@ def fetch_initial_state_data(
else server_default_jitsi_server_url
)
+ state["server_google_meet_app_internal"] = settings.VIDEO_GOOGLE_MEET_AUDIENCE_INTERNAL
+
state["server_can_summarize_topics"] = settings.TOPIC_SUMMARIZATION_MODEL is not None
for channel_field in [
@@ -945,6 +947,9 @@ def fetch_initial_state_data(
state["user_topics"] = [] if user_profile is None else get_user_topics(user_profile)
if want("video_calls"):
+ state["has_google_meet_token"] = (
+ settings_user.third_party_api_state.get("google_meet") is not None
+ )
state["has_webex_token"] = settings_user.third_party_api_state.get("webex") is not None
state["has_zoom_token"] = settings_user.third_party_api_state.get("zoom") is not None
@@ -2029,6 +2034,8 @@ def apply_event(
state["channel_folders"].sort(key=lambda folder: folder["order"])
else:
raise AssertionError("Unexpected event type {type}/{op}".format(**event))
+ elif event["type"] == "has_google_meet_token":
+ state["has_google_meet_token"] = event["value"]
elif event["type"] == "has_webex_token":
state["has_webex_token"] = event["value"]
elif event["type"] == "has_zoom_token":
diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.py
index d6e24f30cc7..1b5fa5e4c43 100644
--- a/zerver/lib/integrations.py
+++ b/zerver/lib/integrations.py
@@ -1033,6 +1033,7 @@ VIDEO_CALL_INTEGRATIONS: list[Integration] = [
Integration(
"constructor-groups", ["video-calling", "communication"], display_name="Constructor Groups"
),
+ Integration("google-meet", ["video-calling", "communication"], display_name="Google Meet"),
Integration("jitsi", ["video-calling", "communication"], display_name="Jitsi Meet"),
Integration(
"nextcloud-talk",
@@ -1218,7 +1219,15 @@ INTEGRATIONS_WITHOUT_SCREENSHOTS = (
# Outgoing integrations
| {"atolio", "email", "onyx"}
# Video call integrations
- | {"big-blue-button", "constructor-groups", "jitsi", "nextcloud-talk", "webex", "zoom"}
+ | {
+ "big-blue-button",
+ "constructor-groups",
+ "google-meet",
+ "jitsi",
+ "nextcloud-talk",
+ "webex",
+ "zoom",
+ }
| {
# these integrations do not send messages
"giphy",
diff --git a/zerver/models/realms.py b/zerver/models/realms.py
index e6f8ae85453..4d27e7916d0 100644
--- a/zerver/models/realms.py
+++ b/zerver/models/realms.py
@@ -687,6 +687,10 @@ class Realm(models.Model):
"name": "Webex",
"id": 8,
},
+ "google_meet": {
+ "name": "Google Meet",
+ "id": 9,
+ },
}
video_chat_provider = models.PositiveSmallIntegerField(
@@ -1134,6 +1138,11 @@ class Realm(models.Model):
settings.VIDEO_WEBEX_CLIENT_ID is None or settings.VIDEO_WEBEX_CLIENT_SECRET is None
):
continue
+ if provider == "google_meet" and (
+ settings.VIDEO_GOOGLE_MEET_CLIENT_ID is None
+ or settings.VIDEO_GOOGLE_MEET_CLIENT_SECRET is None
+ ):
+ continue
enabled_video_chat_providers[provider] = self.VIDEO_CHAT_PROVIDERS[provider]
return enabled_video_chat_providers
diff --git a/zerver/openapi/test_curl_examples.py b/zerver/openapi/test_curl_examples.py
index 4ce28a079d7..6923f5254a3 100644
--- a/zerver/openapi/test_curl_examples.py
+++ b/zerver/openapi/test_curl_examples.py
@@ -38,6 +38,7 @@ UNTESTED_GENERATED_CURL_EXAMPLES = {
# Video call endpoints that need the third-party call provider
# to be configured to test the curl example for the endpoint.
"create-constructor-groups-video-call",
+ "create-google-meet-video-call",
"create-nextcloud-talk-video-call",
"create-webex-video-call",
# Successfully running this example would deactivate the "zulip"
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index 9fd490f4a03..7b02c964a19 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -1228,6 +1228,33 @@ paths:
"value": true,
"id": 0,
}
+ - type: object
+ description: |
+ Event sent to a user's clients when the user completes the OAuth flow
+ for the [Google Meet integration](/help/configure-call-provider).
+ Clients need to know whether initiating Google Meet OAuth is required
+ before creating a Google Meet call.
+
+ **Changes**: New in Zulip 13.0 (feature level 514).
+ properties:
+ id:
+ $ref: "#/components/schemas/EventIdSchema"
+ type:
+ allOf:
+ - $ref: "#/components/schemas/EventTypeSchema"
+ - enum:
+ - has_google_meet_token
+ value:
+ type: boolean
+ description: |
+ A boolean specifying whether the user has a Google Meet access token.
+ additionalProperties: false
+ example:
+ {
+ "type": "has_google_meet_token",
+ "value": true,
+ "id": 0,
+ }
- type: object
description: |
A simple event sent when the set of invitations changes.
@@ -6056,11 +6083,15 @@ paths:
- 6 = Constructor Groups
- 7 = Nextcloud Talk
- 8 = Webex (User OAuth integration)
+ - 9 = Google Meet (User OAuth integration)
Note that only one of the [Zoom integrations][zoom-video-calls] can
be configured on a Zulip server.
- **Changes**: In Zulip 12.0 (feature level 493),
+ **Changes**: In Zulip 13.0 (feature level 514),
+ added the Google Meet option.
+
+ In Zulip 12.0 (feature level 493),
added the Webex OAuth option.
In Zulip 12.0 (feature level 465), added the
@@ -20431,6 +20462,17 @@ paths:
Webex call.
**Changes**: New in Zulip 12.0 (feature level 493).
+ has_google_meet_token:
+ type: boolean
+ description: |
+ Present if `video_calls` is present in `fetch_event_types`.
+
+ A boolean that denotes whether the user has completed the OAuth flow for
+ the [Google Meet integration](/help/configure-call-provider). Clients need
+ to know whether initiating Google Meet OAuth flow is required before
+ creating a Google Meet call.
+
+ **Changes**: New in Zulip 13.0 (feature level 514).
giphy_api_key:
type: string
description: |
@@ -21260,11 +21302,15 @@ paths:
- 6 = Constructor Groups
- 7 = Nextcloud Talk
- 8 = Webex (User OAuth integration)
+ - 9 = Google Meet (User OAuth integration)
Note that only one of the [Zoom integrations][zoom-video-calls] can
be configured on a Zulip server.
- **Changes**: In Zulip 12.0 (feature level 493), added the
+ **Changes**: In Zulip 13.0 (feature level 514), added the
+ Google Meet option.
+
+ In Zulip 12.0 (feature level 493), added the
Webex OAuth option.
In Zulip 12.0 (feature level 465), added the
@@ -22111,6 +22157,19 @@ paths:
since the last request.
**Changes**: New in Zulip 6.0 (feature level 140).
+ server_google_meet_app_internal:
+ type: boolean
+ description: |
+ Present if `realm` is present in `fetch_event_types`.
+
+ Whether a configured Google Meet video call integration should be
+ considered to have an internal, workspace-restricted audience.
+
+ Clients should use this to warn users that the video call feature
+ is restricted to a particular Google Workspace before starting the
+ Google OAuth flow for the Google Meet video call integration.
+
+ **Changes**: New in Zulip 13.0 (feature level 514).
server_jitsi_server_url:
type: string
nullable: true
@@ -27630,6 +27689,48 @@ paths:
"result": "success",
"url": "https://xxkk-7xpz.webex.com/xxkk-7xpz/j.php?MTID=mebb3ba1f366f683bcaec9d32773ce034",
}
+ /calls/google_meet/create:
+ post:
+ tags: ["channels"]
+ operationId: create-google-meet-video-call
+ summary: Create Google Meet video call
+ description: |
+ Create a video call URL for a Google Meet video call.
+
+ Requires the [Google Meet integration](/integrations/google-meet) to be
+ configured on the Zulip server.
+
+ Clients should confirm that the user has completed the OAuth process
+ with Google and has a Google Meet token before attempting to create a
+ video call URL. See the `has_google_meet_token` field in the [`POST
+ /register` response](/api/register-queue), as well as the
+ [`has_google_meet_token` event type](/api/get-events#has_google_meet_token).
+
+ **Changes**: New in Zulip 13.0 (feature level 514).
+ responses:
+ "200":
+ description: Success.
+ content:
+ application/json:
+ schema:
+ allOf:
+ - $ref: "#/components/schemas/JsonSuccessBase"
+ - additionalProperties: false
+ properties:
+ result: {}
+ msg: {}
+ ignored_parameters_unsupported: {}
+ url:
+ description: |
+ The URL for the Google Meet video call.
+ type: string
+ example: "https://meet.google.com/abc-mnop-xyz"
+ example:
+ {
+ "msg": "",
+ "result": "success",
+ "url": "https://meet.google.com/abc-mnop-xyz",
+ }
/calls/constructorgroups/create:
post:
tags: ["channels"]
diff --git a/zerver/signals.py b/zerver/signals.py
index 94f00bbc3ce..250e17a54e0 100644
--- a/zerver/signals.py
+++ b/zerver/signals.py
@@ -103,6 +103,8 @@ def clear_call_tokens_on_logout(
from zerver.actions.video_calls import do_set_video_call_provider_token
if user is not None:
+ if user.third_party_api_state.get("google_meet") is not None:
+ do_set_video_call_provider_token(user, "google_meet", None)
if user.third_party_api_state.get("webex") is not None:
do_set_video_call_provider_token(user, "webex", None)
if user.third_party_api_state.get("zoom") is not None:
diff --git a/zerver/tests/test_create_video_call.py b/zerver/tests/test_create_video_call.py
index 1a8c7942864..d04513a2132 100644
--- a/zerver/tests/test_create_video_call.py
+++ b/zerver/tests/test_create_video_call.py
@@ -1021,3 +1021,128 @@ class NextcloudVideoCallTest(ZulipTestCase):
json = self.assert_json_success(response)
self.assertEqual(json["url"], "https://nextcloud.example.com/index.php/call/abc123token")
+
+
+@override_settings(
+ VIDEO_GOOGLE_MEET_CLIENT_ID="google_client_id",
+ VIDEO_GOOGLE_MEET_CLIENT_SECRET="google_client_secret",
+ VIDEO_GOOGLE_MEET_OAUTH_URL="https://googleoauth.example.com/o/oauth2/v2/auth",
+ VIDEO_GOOGLE_MEET_TOKEN_URL="https://googletoken.example.com/token",
+ VIDEO_GOOGLE_MEET_API_URL="https://meet.example.com/v2/spaces",
+)
+class GoogleMeetVideoCallTest(ZulipTestCase):
+ @override
+ def setUp(self) -> None:
+ super().setUp()
+ self.user = self.example_user("hamlet")
+ self.login_user(self.user)
+
+ def test_register_google_meet_no_settings(self) -> None:
+ with self.settings(VIDEO_GOOGLE_MEET_CLIENT_ID=None):
+ response = self.client_get("/calls/google_meet/register")
+ self.assert_json_error(
+ response,
+ "Google Meet credentials have not been configured",
+ )
+
+ def test_register_google_meet_request(self) -> None:
+ response = self.client_get("/calls/google_meet/register")
+ self.assertEqual(response.status_code, 302)
+ self.assertIn(
+ "https://googleoauth.example.com/o/oauth2/v2/auth",
+ response["Location"],
+ )
+ self.assertIn("access_type=offline", response["Location"])
+ self.assertIn("prompt=consent", response["Location"])
+
+ @responses.activate
+ def test_create_google_meet_link(self) -> None:
+ responses.add(
+ responses.POST,
+ "https://googletoken.example.com/token",
+ json={"access_token": "token", "expires_in": 3600},
+ )
+
+ response = self.client_get(
+ "/calls/google_meet/complete",
+ {"code": "code", "state": '{"realm":"zulip","sid":""}'},
+ )
+ self.assertEqual(response.status_code, 200)
+
+ responses.add(
+ responses.POST,
+ "https://meet.example.com/v2/spaces",
+ json={"meetingUri": "https://meet.google.com/abc-mnop-xyz"},
+ )
+
+ response = self.client_post("/json/calls/google_meet/create")
+ self.assertEqual(
+ responses.calls[-1].request.url,
+ "https://meet.example.com/v2/spaces",
+ )
+ self.assertEqual(
+ responses.calls[-1].request.headers["Authorization"],
+ "Bearer token",
+ )
+ json = self.assert_json_success(response)
+ self.assertEqual(json["url"], "https://meet.google.com/abc-mnop-xyz")
+
+ # Token is cleared on logout; subsequent call must re-authorize.
+ self.logout()
+ self.login_user(self.user)
+
+ response = self.client_post("/json/calls/google_meet/create")
+ self.assert_json_error(response, "Invalid Google Meet access token")
+
+ def test_create_google_meet_realm_redirect(self) -> None:
+ response = self.client_get(
+ "/calls/google_meet/complete",
+ {"code": "code", "state": '{"realm":"zephyr","sid":"somesid"}'},
+ )
+ self.assertEqual(response.status_code, 302)
+ self.assertIn("http://zephyr.testserver/", response["Location"])
+ self.assertIn("somesid", response["Location"])
+
+ def test_create_google_meet_sid_error(self) -> None:
+ response = self.client_get(
+ "/calls/google_meet/complete",
+ {"code": "code", "state": '{"realm":"zulip","sid":"bad"}'},
+ )
+ self.assert_json_error(response, "Invalid Google Meet session identifier")
+
+ @responses.activate
+ def test_create_google_meet_credential_error(self) -> None:
+ responses.add(
+ responses.POST,
+ "https://googletoken.example.com/token",
+ status=400,
+ )
+
+ response = self.client_get(
+ "/calls/google_meet/complete",
+ {"code": "code", "state": '{"realm":"zulip","sid":""}'},
+ )
+ self.assert_json_error(response, "Invalid Google Meet credentials")
+
+ @responses.activate
+ def test_create_google_meet_refresh_error(self) -> None:
+ responses.add(
+ responses.POST,
+ "https://googletoken.example.com/token",
+ json={"access_token": "token", "expires_in": -60},
+ )
+
+ response = self.client_get(
+ "/calls/google_meet/complete",
+ {"code": "code", "state": '{"realm":"zulip","sid":""}'},
+ )
+ self.assertEqual(response.status_code, 200)
+
+ responses.replace(
+ responses.POST,
+ "https://googletoken.example.com/token",
+ status=400,
+ )
+
+ response = self.client_post("/json/calls/google_meet/create")
+ self.assert_json_error(response, "Invalid Google Meet access token")
diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py
index 82738d8b3f8..c75ad3fe71e 100644
--- a/zerver/tests/test_events.py
+++ b/zerver/tests/test_events.py
@@ -189,6 +189,7 @@ from zerver.lib.event_schema import (
check_draft_add,
check_draft_remove,
check_draft_update,
+ check_has_google_meet_token,
check_has_webex_token,
check_has_zoom_token,
check_heartbeat,
@@ -4534,6 +4535,17 @@ class NormalActionsTest(BaseAction):
do_set_video_call_provider_token(self.user_profile, "webex", None)
check_has_webex_token("events[0]", events[0], value=False)
+ def test_has_google_meet_token(self) -> None:
+ with self.verify_action() as events:
+ do_set_video_call_provider_token(
+ self.user_profile, "google_meet", {"access_token": "token"}
+ )
+ check_has_google_meet_token("events[0]", events[0], value=True)
+
+ with self.verify_action() as events:
+ do_set_video_call_provider_token(self.user_profile, "google_meet", None)
+ check_has_google_meet_token("events[0]", events[0], value=False)
+
def test_restart_event(self) -> None:
with self.verify_action(num_events=1, state_change_expected=False):
send_restart_events()
diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py
index f93b1dfa630..a2cd11f7fb6 100644
--- a/zerver/tests/test_home.py
+++ b/zerver/tests/test_home.py
@@ -95,6 +95,7 @@ class HomeTest(ZulipTestCase):
"full_name",
"gif_rating_policy_options",
"giphy_api_key",
+ "has_google_meet_token",
"has_webex_token",
"has_zoom_token",
"idle_queue_timeout_secs",
@@ -251,6 +252,7 @@ class HomeTest(ZulipTestCase):
"server_can_summarize_topics",
"server_emoji_data_url",
"server_generation",
+ "server_google_meet_app_internal",
"server_inline_image_preview",
"server_inline_url_embed_preview",
"server_jitsi_server_url",
diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py
index 82a9e985164..3856fa4b8d6 100644
--- a/zerver/tests/test_realm.py
+++ b/zerver/tests/test_realm.py
@@ -1407,6 +1407,24 @@ class RealmTest(ZulipTestCase):
webex_provider_id,
)
+ google_meet_provider_id = Realm.VIDEO_CHAT_PROVIDERS["google_meet"]["id"]
+ req = {"video_chat_provider": f"{google_meet_provider_id}"}
+
+ with self.settings(VIDEO_GOOGLE_MEET_CLIENT_ID=None):
+ result = self.client_patch("/json/realm", req)
+ self.assert_json_error(result, f"Invalid video_chat_provider {google_meet_provider_id}")
+
+ with self.settings(VIDEO_GOOGLE_MEET_CLIENT_SECRET=None):
+ result = self.client_patch("/json/realm", req)
+ self.assert_json_error(result, f"Invalid video_chat_provider {google_meet_provider_id}")
+
+ result = self.client_patch("/json/realm", req)
+ self.assert_json_success(result)
+ self.assertEqual(
+ get_realm("zulip").video_chat_provider,
+ google_meet_provider_id,
+ )
+
def test_data_deletion_schedule_when_deactivating_realm(self) -> None:
self.login("desdemona")
diff --git a/zerver/views/video_calls.py b/zerver/views/video_calls.py
index 7de366655bc..679b8b7abcd 100644
--- a/zerver/views/video_calls.py
+++ b/zerver/views/video_calls.py
@@ -195,7 +195,7 @@ class OAuthVideoCallProvider(ABC):
token_url: str = NotImplemented
auto_refresh_url: str = NotImplemented
create_meeting_url: str = NotImplemented
- token_key_name: Literal["zoom", "webex"] = NotImplemented
+ token_key_name: Literal["google_meet", "webex", "zoom"] = NotImplemented
def get_token(self, user: UserProfile) -> object | None:
return user.third_party_api_state.get(self.token_key_name)
@@ -373,6 +373,35 @@ class ZoomGeneralOAuthProvider(OAuthVideoCallProvider):
return json_success(request, data={"url": response.json()["join_url"]})
+class GoogleMeetOAuthProvider(OAuthVideoCallProvider):
+ provider_name = "Google Meet"
+ provider_slug = "google_meet"
+ token_key_name = "google_meet"
+
+ def __init__(self) -> None:
+ self.client_id = settings.VIDEO_GOOGLE_MEET_CLIENT_ID
+ self.client_secret = settings.VIDEO_GOOGLE_MEET_CLIENT_SECRET
+ self.authorization_url = settings.VIDEO_GOOGLE_MEET_OAUTH_URL
+ self.token_url = settings.VIDEO_GOOGLE_MEET_TOKEN_URL
+ self.auto_refresh_url = settings.VIDEO_GOOGLE_MEET_TOKEN_URL
+ # https://developers.google.com/workspace/meet/api/reference/rest/v2/spaces/create
+ self.create_meeting_url = settings.VIDEO_GOOGLE_MEET_API_URL
+ self.authorization_scope = "https://www.googleapis.com/auth/meetings.space.created"
+
+ @override
+ def get_meeting_details(self, request: HttpRequest, response: Response) -> HttpResponse:
+ return json_success(request, data={"url": response.json()["meetingUri"]})
+
+ @override
+ def register_user(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
+ # access_type=offline makes Google issue a refresh token alongside
+ # the access token, so Zulip can create meeting links without
+ # requiring the user to re-authorize after the one-hour expiry.
+ # prompt=consent forces the authorization screen each time, ensuring
+ # a fresh refresh token is issued even if Google cached prior consent.
+ return super().register_user(request, access_type="offline", prompt="consent")
+
+
@zulip_login_required
@never_cache
def register_zoom_user(request: HttpRequest) -> HttpResponse:
@@ -385,6 +414,12 @@ def register_webex_user(request: HttpRequest) -> HttpResponse:
return WebexOAuthProvider().register_user(request=request)
+@zulip_login_required
+@never_cache
+def register_google_meet_user(request: HttpRequest) -> HttpResponse:
+ return GoogleMeetOAuthProvider().register_user(request=request)
+
+
class StateDictRealm(TypedDict):
realm: str
sid: str
@@ -445,6 +480,20 @@ def complete_webex_user(
return WebexOAuthProvider().complete_user(request, code=code, sid=state["sid"])
+@never_cache
+@zulip_login_required
+@typed_endpoint
+def complete_google_meet_user(
+ request: HttpRequest,
+ *,
+ code: str,
+ state: Json[StateDictRealm],
+) -> HttpResponse:
+ if get_subdomain(request) != state["realm"]:
+ return redirect(urljoin(get_realm(state["realm"]).url, request.get_full_path()))
+ return GoogleMeetOAuthProvider().complete_user(request, code=code, sid=state["sid"])
+
+
@cache_with_key(zoom_server_access_token_cache_key, timeout=3600 - 240)
def get_zoom_server_to_server_access_token(account_id: str) -> str:
if settings.VIDEO_ZOOM_CLIENT_ID is None:
@@ -570,6 +619,11 @@ def make_webex_video_call(request: HttpRequest, user: UserProfile) -> HttpRespon
return WebexOAuthProvider().make_video_call(request, user, payload=payload)
+@typed_endpoint_without_parameters
+def make_google_meet_video_call(request: HttpRequest, user: UserProfile) -> HttpResponse:
+ return GoogleMeetOAuthProvider().make_video_call(request, user)
+
+
@csrf_exempt
@require_POST
@typed_endpoint_without_parameters
diff --git a/zproject/default_settings.py b/zproject/default_settings.py
index 66b903cf8b3..d5a8d969923 100644
--- a/zproject/default_settings.py
+++ b/zproject/default_settings.py
@@ -133,6 +133,12 @@ VIDEO_ZOOM_CLIENT_SECRET = get_secret("video_zoom_client_secret")
VIDEO_WEBEX_API_URL: str = "https://webexapis.com/v1/"
VIDEO_WEBEX_CLIENT_ID = get_secret("video_webex_client_id", development_only=True)
VIDEO_WEBEX_CLIENT_SECRET = get_secret("video_webex_client_secret")
+VIDEO_GOOGLE_MEET_OAUTH_URL: str = "https://accounts.google.com/o/oauth2/v2/auth"
+VIDEO_GOOGLE_MEET_TOKEN_URL: str = "https://oauth2.googleapis.com/token"
+VIDEO_GOOGLE_MEET_API_URL: str = "https://meet.googleapis.com/v2/spaces"
+VIDEO_GOOGLE_MEET_CLIENT_ID = get_secret("video_google_meet_client_id", development_only=True)
+VIDEO_GOOGLE_MEET_CLIENT_SECRET = get_secret("video_google_meet_client_secret")
+VIDEO_GOOGLE_MEET_AUDIENCE_INTERNAL: bool = False
# Email gateway
EMAIL_GATEWAY_PATTERN = ""
diff --git a/zproject/prod_settings_template.py b/zproject/prod_settings_template.py
index 1e766a6cea4..1357afdafcc 100644
--- a/zproject/prod_settings_template.py
+++ b/zproject/prod_settings_template.py
@@ -801,6 +801,15 @@ SOCIAL_AUTH_SAML_SUPPORT_CONTACT = {
## /etc/zulip/zulip-secrets.conf to enable Webex as a call provider.
# VIDEO_WEBEX_CLIENT_ID = "<your Webex client ID>"
+## Controls the Google Meet video call integration. See:
+## https://zulip.readthedocs.io/en/latest/production/video-calls.html
+## You must also set video_google_meet_client_secret in
+## /etc/zulip/zulip-secrets.conf to enable Google Meet as a call provider.
+# VIDEO_GOOGLE_MEET_CLIENT_ID = "<your Google Meet client ID>"
+## Whether the audience type configured for your Google Meet client app
+## is internal, and restricted to a specific Google Workspace, or not.
+# VIDEO_GOOGLE_MEET_AUDIENCE_INTERNAL = False
+
## Controls the Jitsi Meet video call integration. By default, the
## integration uses the SaaS https://meet.jit.si server. You can specify
## your own Jitsi Meet server, or if you'd like to disable the
diff --git a/zproject/test_extra_settings.py b/zproject/test_extra_settings.py
index 83fd27c7584..b4dc1aef310 100644
--- a/zproject/test_extra_settings.py
+++ b/zproject/test_extra_settings.py
@@ -204,6 +204,9 @@ VIDEO_ZOOM_CLIENT_SECRET = "client_secret"
VIDEO_WEBEX_CLIENT_ID = "client_id"
VIDEO_WEBEX_CLIENT_SECRET = "client_secret"
+VIDEO_GOOGLE_MEET_CLIENT_ID = "client_id"
+VIDEO_GOOGLE_MEET_CLIENT_SECRET = "client_secret"
+
BIG_BLUE_BUTTON_SECRET = "123"
BIG_BLUE_BUTTON_URL = "https://bbb.example.com/bigbluebutton/"
diff --git a/zproject/urls.py b/zproject/urls.py
index f3a133ed8df..2ffe143da16 100644
--- a/zproject/urls.py
+++ b/zproject/urls.py
@@ -262,6 +262,7 @@ from zerver.views.users import (
update_user_by_id_api,
)
from zerver.views.video_calls import (
+ complete_google_meet_user,
complete_webex_user,
complete_zoom_user,
create_nextcloud_talk_url,
@@ -269,8 +270,10 @@ from zerver.views.video_calls import (
get_bigbluebutton_url,
join_bigbluebutton,
make_constructor_groups_video_call,
+ make_google_meet_video_call,
make_webex_video_call,
make_zoom_video_call,
+ register_google_meet_user,
register_webex_user,
register_zoom_user,
)
@@ -595,6 +598,7 @@ v1_api_and_json_patterns = [
# Used to generate a Zoom video call URL
rest_path("calls/zoom/create", POST=make_zoom_video_call),
rest_path("calls/webex/create", POST=make_webex_video_call),
+ rest_path("calls/google_meet/create", POST=make_google_meet_video_call),
# Used to generate a BigBlueButton video call URL
rest_path("calls/bigbluebutton/create", GET=get_bigbluebutton_url),
# Used to generate a Constructor Groups video call URL
@@ -735,6 +739,9 @@ i18n_urls = [
# access token.
path("calls/webex/register", register_webex_user),
path("calls/webex/complete", complete_webex_user),
+ # Used to complete Google Meet OAuth flow to get user's access token.
+ path("calls/google_meet/register", register_google_meet_user),
+ path("calls/google_meet/complete", complete_google_meet_user),
# Used to join a BigBlueButton video call
path("calls/bigbluebutton/join", join_bigbluebutton),
# Integrations documentation