Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(youtube): Custom API Call Action #4611

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/pieces/community/youtube/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@activepieces/piece-youtube",
"version": "0.3.4"
"version": "0.3.5"
}
21 changes: 17 additions & 4 deletions packages/pieces/community/youtube/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { PieceAuth, createPiece } from '@activepieces/pieces-framework';
import {
createPiece,
OAuth2PropertyValue,
} from '@activepieces/pieces-framework';
import { PieceCategory } from '@activepieces/shared';
import { youtubeNewVideoTrigger } from './lib/triggers/new-video.trigger';
import { youtubeAuth } from './lib/common/auth';
import { createCustomApiCallAction } from '@activepieces/pieces-common';

export const youtube = createPiece({
displayName: 'YouTube',
Expand All @@ -10,8 +15,16 @@ export const youtube = createPiece({
minimumSupportedRelease: '0.5.0',
logoUrl: 'https://cdn.activepieces.com/pieces/youtube.png',
categories: [PieceCategory.CONTENT_AND_FILES],
auth: PieceAuth.None(),
authors: ["abaza738","kishanprmr","khaledmashaly","abuaboud"],
actions: [],
auth: youtubeAuth,
authors: ['abaza738', 'kishanprmr', 'khaledmashaly', 'abuaboud'],
actions: [
createCustomApiCallAction({
baseUrl: () => 'https://www.googleapis.com/youtube/v3',
auth: youtubeAuth,
authMapping: (auth) => ({
Authorization: `Bearer ${(auth as OAuth2PropertyValue).access_token}`,
}),
}),
],
triggers: [youtubeNewVideoTrigger],
});
30 changes: 30 additions & 0 deletions packages/pieces/community/youtube/src/lib/common/auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { PieceAuth } from '@activepieces/pieces-framework';

export const youtubeAuth = PieceAuth.OAuth2({
description: `
1. Sign in to [Google Cloud Console](https://console.cloud.google.com/).
2. Create a new project or you can use existing one.
3. Go to **APIs & Services** and click **Enable APIs & Services**.
4. Search for **YouTube API** in the search bar and enable it.
5. Go to **OAuth consent screen** and select **External** type and click create.
6. Fill App Name, User Support Email, and Developer Contact Information. Click on the Save and Continue button.
7. Click on **Add or Remove Scopes** and add following scopes and click update.
- https://www.googleapis.com/auth/youtube
- https://www.googleapis.com/auth/youtube.readonly
- https://www.googleapis.com/auth/youtube.upload
8. Click Save and Continue to finish the Scopes step.
9. Click on the Add Users button and add a test email You can add your own email).Then finally click Save and Continue to finish the Test Users portion.
10. Go to **Credentials**. Click on the **Create Credentials** button and select the **OAuth client ID** option.
11. Select the application type as **Web Application** and fill the Name field.
12. Add https://www.cloud.activepieces.com/redirect in **Authorized redirect URIs** field, and click on the Create button.
13. Copy **Client ID** and **Client Secret**.`,

authUrl: 'https://accounts.google.com/o/oauth2/auth',
tokenUrl: 'https://oauth2.googleapis.com/token',
required: true,
scope: [
'https://www.googleapis.com/auth/youtube',
'https://www.googleapis.com/auth/youtube.readonly',
'https://www.googleapis.com/auth/youtube.upload',
],
});