Skip to content

Commit cc2ea2c

Browse files
authored
Merge pull request #13 from kagenti/feat/youtube-connector
feat(apps): add YouTube connector
2 parents 3ace5b1 + dc25e9f commit cc2ea2c

4 files changed

Lines changed: 83 additions & 0 deletions

File tree

apps/gateway/src/apps.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,24 @@ static APP_PROVIDERS: &[AppProvider] = &[
257257
}],
258258
refresh: Some(&GOOGLE_REFRESH),
259259
},
260+
AppProvider {
261+
provider: "youtube",
262+
display_name: "YouTube",
263+
host_rules: &[
264+
HostRule {
265+
host: "youtube.googleapis.com",
266+
path_prefix: None,
267+
strategy: AuthStrategy::Bearer,
268+
},
269+
// Legacy endpoint — some clients still use www.googleapis.com/youtube/
270+
HostRule {
271+
host: "www.googleapis.com",
272+
path_prefix: Some("/youtube/"),
273+
strategy: AuthStrategy::Bearer,
274+
},
275+
],
276+
refresh: Some(&GOOGLE_REFRESH),
277+
},
260278
AppProvider {
261279
provider: "google-health",
262280
display_name: "Google Health",
@@ -712,6 +730,10 @@ mod tests {
712730
providers_for_host("health.googleapis.com"),
713731
vec!["google-health"]
714732
);
733+
assert_eq!(
734+
providers_for_host("youtube.googleapis.com"),
735+
vec!["youtube"]
736+
);
715737
}
716738

717739
#[test]
@@ -729,6 +751,7 @@ mod tests {
729751
("google-meet", "meet.googleapis.com"),
730752
("google-photos", "photoslibrary.googleapis.com"),
731753
("google-health", "health.googleapis.com"),
754+
("youtube", "youtube.googleapis.com"),
732755
];
733756
for (provider, host) in &hosts {
734757
let injections = build_app_injections(provider, host, "ya29.test");
@@ -856,6 +879,9 @@ mod tests {
856879

857880
let result = provider_for_host_and_path("www.googleapis.com", "/drive/v3/files");
858881
assert_eq!(result, Some(("google-drive", "Google Drive")));
882+
883+
let result = provider_for_host_and_path("www.googleapis.com", "/youtube/v3/playlists");
884+
assert_eq!(result, Some(("youtube", "YouTube")));
859885
}
860886

861887
#[test]

apps/web/public/icons/youtube.svg

Lines changed: 4 additions & 0 deletions
Loading

apps/web/src/lib/apps/registry.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { googleSlides } from "./google-slides";
1717
import { googleTasks } from "./google-tasks";
1818
import { resend } from "./resend";
1919
import { spotify } from "./spotify";
20+
import { youtube } from "./youtube";
2021

2122
export const apps: AppDefinition[] = [
2223
github,
@@ -37,6 +38,7 @@ export const apps: AppDefinition[] = [
3738
googleTasks,
3839
resend,
3940
spotify,
41+
youtube,
4042
];
4143

4244
export const getApp = (id: string): AppDefinition | undefined =>

apps/web/src/lib/apps/youtube.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import type { AppDefinition } from "./types";
2+
import {
3+
buildGoogleAuthUrl,
4+
exchangeGoogleCode,
5+
googleConfigFields,
6+
googleEnvDefaults,
7+
} from "./google-oauth";
8+
9+
export const youtube: AppDefinition = {
10+
id: "youtube",
11+
name: "YouTube",
12+
icon: "/icons/youtube.svg",
13+
description:
14+
"Read your channels, playlists, playlist items, and subscriptions.",
15+
connectionMethod: {
16+
type: "oauth",
17+
defaultScopes: [
18+
"openid",
19+
"email",
20+
"profile",
21+
"https://www.googleapis.com/auth/youtube.readonly",
22+
],
23+
permissions: [
24+
{
25+
scope: "https://www.googleapis.com/auth/youtube.readonly",
26+
name: "YouTube account",
27+
description: "Channels, playlists, subscriptions, and uploads",
28+
access: "read",
29+
},
30+
{
31+
scope: "https://www.googleapis.com/auth/userinfo.email",
32+
name: "Email address",
33+
description: "View your email address",
34+
access: "read",
35+
},
36+
{
37+
scope: "https://www.googleapis.com/auth/userinfo.profile",
38+
name: "Profile",
39+
description: "Name and profile picture",
40+
access: "read",
41+
},
42+
],
43+
buildAuthUrl: buildGoogleAuthUrl,
44+
exchangeCode: exchangeGoogleCode,
45+
},
46+
available: true,
47+
configurable: {
48+
fields: googleConfigFields,
49+
envDefaults: googleEnvDefaults,
50+
},
51+
};

0 commit comments

Comments
 (0)