Difference between revisions of "Youtube API Integration With Safesquid To Allow Specific YouTube Videos"

From Secure Web Gateway
Share/Save/Bookmark
Jump to: navigation, search
Line 2: Line 2:
 
= Overview =
 
= Overview =
  
YouTube has huge number of videos.YouTube provides a lost of Educational Content used by Students, Faculty, Corporate Training etc. On the other hand YouTube also provide a lots<br/> of entertainment videos, Cooking videos, web series etc.<br/> Access to all those YouTube videos without restriction, reduces work productivity and increases unnecessary bandwidth Utilization.
+
YouTube has a huge number of videos.YouTube provides a lost of Educational Content used by Students, Faculty, Corporate Training, etc. On the other hand YouTube also provide a lot<br/> of entertainment videos, Cooking videos, web series etc.<br/> Access to all those YouTube videos without restriction, reduces work productivity and increases unnecessary bandwidth Utilization.
  
Depending upon the organization what kind of video content do they want to allow for their users. Any Enterprise would not recommend users to utilize their productive time in unwanted YouTube videos.<br/> YouTube should be used for Productive purposes like learning, Marketing etc.
+
Depending upon the organization, what kind of video content do they want to allow for their users. Any Enterprise would not recommend users to utilize their productive time in unwanted YouTube videos.<br/> YouTube should be used for Productive purposes like learning, Marketing etc.
  
 
Allowing unwanted contents reduces work productivity and increases unnecessary bandwidth.
 
Allowing unwanted contents reduces work productivity and increases unnecessary bandwidth.
  
YouTube API provided by YouTube, provides a lots of Information about YouTube Videos.It can be used to identify the category of that particular video.
+
YouTube API provided by YouTube, provides a lot&nbsp;of Information about YouTube Videos.It can be used to identify the category of that particular video.
  
SafeSquid SWG helps to Integrate YouTube API which allows SafeSquid to Identify the Category of the Requested YouTube Video.These Categories are inbuilt in SafeSquid SWG.Now Policies can be created on the basis of categories so that Specific category of YouTube Videos can be allow/block easily.&nbsp;
+
SafeSquid SWG helps to Integrate YouTube API which allows SafeSquid to Identify the Category of the Requested YouTube Video.These Categories are inbuilt in SafeSquid SWG.Now Policies can be created on the basis of categories so that Specific category of YouTube Videos can allow/block easily.&nbsp;
  
 
= Client Scenario (Case Study) =
 
= Client Scenario (Case Study) =
Line 20: Line 20:
 
*You need YouTube Channel-ID and List-ID of playlist, you want to allow.  
 
*You need YouTube Channel-ID and List-ID of playlist, you want to allow.  
 
*You have to extract Channel-ID and List-ID of the playlist from YouTube URL before creating policies in SafeSquid.  
 
*You have to extract Channel-ID and List-ID of the playlist from YouTube URL before creating policies in SafeSquid.  
<div class="content">Mr.Haresh is the system administrator of Ganpat University. From last few months he received the request from faculty for allowing many other videos/Playlist/channel etc.<br/> Of course all the videos/Playlist/channel etc. are educational and knowledge sharing.<br/> But he face some difficulty for extracting Channel-ID and List-ID of the requested playlist/channel regularly.</div> <div class="content">SafeSquid SWG has given them the funtastic solution for Mr.Haresh difficulty.<br/> The latest Version of SafeSquid (Versions <span style="font-size:11.0pt; line-height:115%; font-family:">August </span> <span data-dobid="hdw">onward</span>) includes '''YouTube API Integration with SafeSquid-SWG'''.That means you can now create Policies on the basis of YouTube Categories.<br/> You can now allow/block specific category of videos on YouTube.</div> <div class="content">
+
<div class="content">Mr.Haresh is the system administrator of Ganpat University. From last few months he received the request from faculty for allowing many other videos/Playlist/channel etc.<br/> Of course all the videos/Playlist/channel etc. are educational and knowledge sharing.<br/> But he face some difficulty for extracting Channel-ID and List-ID of the requested playlist/channel regularly.</div> <div class="content">SafeSquid SWG has given them the funtastic solution for Mr.Haresh difficulty.<br/> The latest Version of SafeSquid (Versions <span style="font-size:11.0pt; line-height:115%; font-family:">August </span> <span data-dobid="hdw">onward</span>) includes '''YouTube API Integration with SafeSquid-SWG'''.That means you can now create Policies on the basis of YouTube Categories.<br/> You can now allow/block specific category of videos on YouTube.</div> <div class="content">
{| style="width: 100%" cellspacing="1" cellpadding="1" border="0"
+
{| border="0" cellpadding="1" cellspacing="1" style="width: 100%"
 
|-
 
|-
 
| [[File:YouTube Category.PNG|border|center|YouTube Category.PNG|link=]]
 
| [[File:YouTube Category.PNG|border|center|YouTube Category.PNG|link=]]
Line 37: Line 37:
 
Go To [https://console.developers.google.com/apis/library https://console.developers.google.com/apis/library]
 
Go To [https://console.developers.google.com/apis/library https://console.developers.google.com/apis/library]
  
{| style="width: 100%" cellspacing="1" cellpadding="1" border="0"
+
{| border="0" cellpadding="1" cellspacing="1" style="width: 100%"
 
|-
 
|-
 
| [[File:YouTube API (1).PNG|border|center|YouTube API (1).PNG|link=]]  
 
| [[File:YouTube API (1).PNG|border|center|YouTube API (1).PNG|link=]]  
Line 50: Line 50:
 
|-
 
|-
 
| [[File:YouTube API (3).PNG|border|center|YouTube API (3).PNG|link=]]  
 
| [[File:YouTube API (3).PNG|border|center|YouTube API (3).PNG|link=]]  
== <span style="font-size:11.0pt; line-height:115%; font-family:">NAME AS&nbsp;: YouTubeAPI-For-SafeSquid</span> ==
+
== <span style="font-size:11.0pt; line-height:115%; font-family:">NAME AS&nbsp;: YouTubeAPI-For-SafeSquid</span> ==
  
 
|-
 
|-
Line 100: Line 100:
 
*Go to the path using below command&nbsp;:  
 
*Go to the path using below command&nbsp;:  
  
{| width="547" cellspacing="1" cellpadding="1" border="0"
+
{| border="0" cellpadding="1" cellspacing="1" width="547"
 
|-
 
|-
| style="width: 549px" | <div style="background:#eee; border:1px solid #ccc; padding:5px 10px">
+
| style="width: 549px" | <div style="background:#eee; border:1px solid #ccc; padding:5px 10px">
 
root@safesquid-swg:/var/lib/safesquid#<code>cd /var/lib/safesquid/</code>
 
root@safesquid-swg:/var/lib/safesquid#<code>cd /var/lib/safesquid/</code>
 
</div>  
 
</div>  
Line 109: Line 109:
 
*Create the directory using below command&nbsp;:  
 
*Create the directory using below command&nbsp;:  
  
{| style="width: 557px" cellspacing="1" cellpadding="1" border="0"
+
{| border="0" cellpadding="1" cellspacing="1" style="width: 557px"
 
|-
 
|-
| style="width: 549px" | <div style="background:#eee; border:1px solid #ccc; padding:5px 10px">
+
| style="width: 549px" | <div style="background:#eee; border:1px solid #ccc; padding:5px 10px">
 
root@safesquid-swg:/var/lib/safesquid#<code>mkdir youtube</code>
 
root@safesquid-swg:/var/lib/safesquid#<code>mkdir youtube</code>
 
</div>  
 
</div>  
Line 118: Line 118:
 
*Give the permission using below command&nbsp;:  
 
*Give the permission using below command&nbsp;:  
  
{| style="width: 557px" cellspacing="1" cellpadding="1" border="0"
+
{| border="0" cellpadding="1" cellspacing="1" style="width: 557px"
 
|-
 
|-
| style="width: 549px" | <div style="background:#eee; border:1px solid #ccc; padding:5px 10px"><code>chmod 774 youtube</code></div>  
+
| style="width: 549px" | <div style="background:#eee; border:1px solid #ccc; padding:5px 10px"><code>chmod 774 youtube</code></div>  
 
|}
 
|}
  
{| style="width: 557px" cellspacing="1" cellpadding="1" border="0"
+
{| border="0" cellpadding="1" cellspacing="1" style="width: 557px"
 
|-
 
|-
| style="width: 549px" | <div style="background:#eee; border:1px solid #ccc; padding:5px 10px"><code>chown ssquid:root youtube</code></div>  
+
| style="width: 549px" | <div style="background:#eee; border:1px solid #ccc; padding:5px 10px"><code>chown ssquid:root youtube</code></div>  
 
|}
 
|}
  
{| style="width: 557px" cellspacing="1" cellpadding="1" border="0"
+
{| border="0" cellpadding="1" cellspacing="1" style="width: 557px"
 
|-
 
|-
| style="width: 549px" | <div style="background:#eee; border:1px solid #ccc; padding:5px 10px">
+
| style="width: 549px" | <div style="background:#eee; border:1px solid #ccc; padding:5px 10px">
 
root@safesquid-swg:/var/lib/safesquid# ll<br/> total 56<br/> drwxrwxr--&nbsp;&nbsp; 12 ssquid root&nbsp; 4096 Aug 29 15:35 ./<br/> drwxr-xr-x&nbsp;&nbsp;&nbsp; 48 root&nbsp;&nbsp; root&nbsp; 4096 Jul&nbsp; 4 19:06 ../<br/> drwxrwxr-- &nbsp; &nbsp; 3 ssquid root&nbsp; 4096 Jan 21&nbsp;&nbsp; 2019&nbsp; application_signatures/<br/> drwxrwxr-- &nbsp; &nbsp; 2 ssquid root&nbsp; 4096 Sep&nbsp; 5&nbsp;&nbsp; 14:03 category/<br/> drwxrwxr--&nbsp;&nbsp;&nbsp;&nbsp; 3 ssquid root&nbsp; 4096 Apr&nbsp; 2&nbsp;&nbsp;&nbsp; 18:44 content_signatures/<br/> drwxrwxr-- &nbsp; &nbsp; 2 ssquid root&nbsp; 4096 Jan 21&nbsp;&nbsp; 2019&nbsp; imgfilter/<br/> drwxrwxr--&nbsp;&nbsp;&nbsp;&nbsp; 3 ssquid root 12288 Sep&nbsp; 5&nbsp; 13:47 sqscan/<br/> drwxrwxr-- &nbsp; &nbsp; 3 ssquid root&nbsp; 4096 May 30&nbsp; 14:17 sscore/<br/> drwxrwxr-- &nbsp; &nbsp; 4 ssquid root&nbsp; 4096 Sep&nbsp; 5&nbsp;&nbsp; 14:03 sscore2/<br/> drwxrwxr--&nbsp;&nbsp;&nbsp;&nbsp; 2 ssquid root&nbsp; 4096 Jun 13&nbsp;&nbsp; 19:12 ssqore/<br/> drwxrwxr--&nbsp;&nbsp;&nbsp;&nbsp; 4 ssquid root&nbsp; 4096 Sep&nbsp; 5&nbsp;&nbsp; 14:03 svscan/<br/> '''drwxrwxr--&nbsp; 2 ssquid root&nbsp; 4096 Aug 23 14:53 youtube'''/
 
root@safesquid-swg:/var/lib/safesquid# ll<br/> total 56<br/> drwxrwxr--&nbsp;&nbsp; 12 ssquid root&nbsp; 4096 Aug 29 15:35 ./<br/> drwxr-xr-x&nbsp;&nbsp;&nbsp; 48 root&nbsp;&nbsp; root&nbsp; 4096 Jul&nbsp; 4 19:06 ../<br/> drwxrwxr-- &nbsp; &nbsp; 3 ssquid root&nbsp; 4096 Jan 21&nbsp;&nbsp; 2019&nbsp; application_signatures/<br/> drwxrwxr-- &nbsp; &nbsp; 2 ssquid root&nbsp; 4096 Sep&nbsp; 5&nbsp;&nbsp; 14:03 category/<br/> drwxrwxr--&nbsp;&nbsp;&nbsp;&nbsp; 3 ssquid root&nbsp; 4096 Apr&nbsp; 2&nbsp;&nbsp;&nbsp; 18:44 content_signatures/<br/> drwxrwxr-- &nbsp; &nbsp; 2 ssquid root&nbsp; 4096 Jan 21&nbsp;&nbsp; 2019&nbsp; imgfilter/<br/> drwxrwxr--&nbsp;&nbsp;&nbsp;&nbsp; 3 ssquid root 12288 Sep&nbsp; 5&nbsp; 13:47 sqscan/<br/> drwxrwxr-- &nbsp; &nbsp; 3 ssquid root&nbsp; 4096 May 30&nbsp; 14:17 sscore/<br/> drwxrwxr-- &nbsp; &nbsp; 4 ssquid root&nbsp; 4096 Sep&nbsp; 5&nbsp;&nbsp; 14:03 sscore2/<br/> drwxrwxr--&nbsp;&nbsp;&nbsp;&nbsp; 2 ssquid root&nbsp; 4096 Jun 13&nbsp;&nbsp; 19:12 ssqore/<br/> drwxrwxr--&nbsp;&nbsp;&nbsp;&nbsp; 4 ssquid root&nbsp; 4096 Sep&nbsp; 5&nbsp;&nbsp; 14:03 svscan/<br/> '''drwxrwxr--&nbsp; 2 ssquid root&nbsp; 4096 Aug 23 14:53 youtube'''/
 
</div>  
 
</div>  
Line 137: Line 137:
 
*Go to youtube directory using command&nbsp;:  
 
*Go to youtube directory using command&nbsp;:  
  
{| style="width: 557px" cellspacing="1" cellpadding="1" border="0"
+
{| border="0" cellpadding="1" cellspacing="1" style="width: 557px"
 
|-
 
|-
| style="width: 549px" | <div style="background:#eee; border:1px solid #ccc; padding:5px 10px">
+
| style="width: 549px" | <div style="background:#eee; border:1px solid #ccc; padding:5px 10px">
 
root@safesquid-swg:/var/lib/safesquid#<code>cd youtube</code>
 
root@safesquid-swg:/var/lib/safesquid#<code>cd youtube</code>
 
</div>  
 
</div>  
Line 146: Line 146:
 
*Copy YouTube API Key using WinSCP or any other tool at given path /var/lib/safesquid/youtube/  
 
*Copy YouTube API Key using WinSCP or any other tool at given path /var/lib/safesquid/youtube/  
  
{| style="width: 557px" cellspacing="1" cellpadding="1" border="0"
+
{| border="0" cellpadding="1" cellspacing="1" style="width: 557px"
 
|-
 
|-
| style="width: 549px" | <div style="background:#eee; border:1px solid #ccc; padding:5px 10px">
+
| style="width: 549px" | <div style="background:#eee; border:1px solid #ccc; padding:5px 10px">
 
root@safesquid-swg:/var/lib/safesquid/youtube# ll<br/> total 16<br/> drwxrwxr--&nbsp; 2 ssquid root 4096 Aug 23 14:53 ./<br/> drwxrwxr-- 12 ssquid root 4096 Aug 29 15:35 ../<br/> '''-rw-rw-r--&nbsp; 1 ssquid root&nbsp;&nbsp; 40 Jul&nbsp; 3 14:11 keys'''<br/> -rw-rw-r--&nbsp; 1 ssquid root&nbsp; 947 Jul&nbsp; 3 14:12 legends
 
root@safesquid-swg:/var/lib/safesquid/youtube# ll<br/> total 16<br/> drwxrwxr--&nbsp; 2 ssquid root 4096 Aug 23 14:53 ./<br/> drwxrwxr-- 12 ssquid root 4096 Aug 29 15:35 ../<br/> '''-rw-rw-r--&nbsp; 1 ssquid root&nbsp;&nbsp; 40 Jul&nbsp; 3 14:11 keys'''<br/> -rw-rw-r--&nbsp; 1 ssquid root&nbsp; 947 Jul&nbsp; 3 14:12 legends
 
</div>  
 
</div>  
Line 155: Line 155:
 
*After adding key, the file will look like this  
 
*After adding key, the file will look like this  
  
{| style="width: 557px" cellspacing="1" cellpadding="1" border="0"
+
{| border="0" cellpadding="1" cellspacing="1" style="width: 557px"
 
|-
 
|-
| style="width: 549px" | <div style="background:#eee; border:1px solid #ccc; padding:5px 10px">root@safesquid-swg:<code>cat /var/lib/safesquid/youtube/keys</code></div> <div style="background:#eee; border:1px solid #ccc; padding:5px 10px">AIz******************************o</div>  
+
| style="width: 549px" | <div style="background:#eee; border:1px solid #ccc; padding:5px 10px">root@safesquid-swg:<code>cat /var/lib/safesquid/youtube/keys</code></div> <div style="background:#eee; border:1px solid #ccc; padding:5px 10px">AIz******************************o</div>  
 
|}
 
|}
  
 
*After doing so, you just need to '''RESTART SafeSquid Service '''from SafeSquid Interface or by command line.  
 
*After doing so, you just need to '''RESTART SafeSquid Service '''from SafeSquid Interface or by command line.  
  
{| style="width: 557px" cellspacing="1" cellpadding="1" border="0"
+
{| border="0" cellpadding="1" cellspacing="1" style="width: 557px"
 
|-
 
|-
| style="width: 549px" | <div style="background:#eee; border:1px solid #ccc; padding:5px 10px"><code>/etc/init.d/safesquid restart</code></div>  
+
| style="width: 549px" | <div style="background:#eee; border:1px solid #ccc; padding:5px 10px"><code>/etc/init.d/safesquid restart</code></div>  
 
|}
 
|}
  

Revision as of 14:54, 10 September 2019

Overview

YouTube has a huge number of videos.YouTube provides a lost of Educational Content used by Students, Faculty, Corporate Training, etc. On the other hand YouTube also provide a lot
of entertainment videos, Cooking videos, web series etc.
Access to all those YouTube videos without restriction, reduces work productivity and increases unnecessary bandwidth Utilization.

Depending upon the organization, what kind of video content do they want to allow for their users. Any Enterprise would not recommend users to utilize their productive time in unwanted YouTube videos.
YouTube should be used for Productive purposes like learning, Marketing etc.

Allowing unwanted contents reduces work productivity and increases unnecessary bandwidth.

YouTube API provided by YouTube, provides a lot of Information about YouTube Videos.It can be used to identify the category of that particular video.

SafeSquid SWG helps to Integrate YouTube API which allows SafeSquid to Identify the Category of the Requested YouTube Video.These Categories are inbuilt in SafeSquid SWG.Now Policies can be created on the basis of categories so that Specific category of YouTube Videos can allow/block easily. 

Client Scenario (Case Study)

Ganpat University provides graduate programs to various colleges. All the staff’s PC/Laptop traffic is going via SafeSquid SWG.
Ganpat University wants to block entire youtube.com for faculty and students, but wants some of the YouTube channels allowed which are helpful for faculty/students.
Ganpat University challenges are:
  • All staff/Students should not be allowed to access www.youtube.com. If any faculty/student try to access YouTube then he/she should get blocked template.
  • Only few of the specified YouTube channel and its playlist should be allowed. These YouTube channel contains educational and knowledge sharing videos.
SafeSquid SWG give them solution for the above requirement.
  • You can achieve this by creating policy in Request Profiles Section and bind it with policies in Access Profiles Section.
  • You need YouTube Channel-ID and List-ID of playlist, you want to allow.
  • You have to extract Channel-ID and List-ID of the playlist from YouTube URL before creating policies in SafeSquid.
Mr.Haresh is the system administrator of Ganpat University. From last few months he received the request from faculty for allowing many other videos/Playlist/channel etc.
Of course all the videos/Playlist/channel etc. are educational and knowledge sharing.
But he face some difficulty for extracting Channel-ID and List-ID of the requested playlist/channel regularly.
SafeSquid SWG has given them the funtastic solution for Mr.Haresh difficulty.
The latest Version of SafeSquid (Versions August onward) includes YouTube API Integration with SafeSquid-SWG.That means you can now create Policies on the basis of YouTube Categories.
You can now allow/block specific category of videos on YouTube.
YouTube Category.PNG

Prerequisites

HTTPS Inspection should be enabled in SafeSquid. If not enabled, you can check our document - How to enable HTTPS Inspection

Create a YouTube V3 API using your Google Account.

  • To Request the Category of Specific Video
  • To extract Video Category from Video ID

Go To https://console.developers.google.com/apis/library

YouTube API (1).PNG

 

Note:What happens over here is If you don’t Create a Project over here, Google will Automatically Create a new Project for you Named as “My First Project” when you ENABLE the YouTube Data API v3.
People doing it for the first time and have requirement to use YouTube Data API v3 to integrate it with SafeSquid-SWG.
I recommend creating a New Project with a Proper name so that you can later identify it.
Since they have specified Per Day Quota i.e No of Request to find Information about a Particular video and its details.
Make sure that this Google Account is not using YouTube API for any other purposes as this will reduce the No of Request

CREATE A NEW PROJECT

YouTube API (2).PNG
YouTube API (3).PNG

NAME AS : YouTubeAPI-For-SafeSquid

YouTube API (4).PNG
YouTube API (5).PNG

SELECT A PROJECT

YouTube API (6).PNG
YouTube API (7).PNG

 

YouTube API (8).PNG

 

ENABLE YOUTUBE DATA API V3

YouTube API (9).PNG

 

CREATE CREDENTIALS

YouTube API (10).PNG
YouTube API (11).PNG

 

SELECT API KEY

YouTube API (12).PNG
YouTube API (13).PNG

 

Integrate the YouTube API Key in SafeSquid.

To identify the category of the YouTube video

Now we are going to Integrating this Key in SafeSquid-SWG.

To do that, Go to SafeSquid console.

  • Go to the path using below command :

root@safesquid-swg:/var/lib/safesquid#cd /var/lib/safesquid/

  • Create the directory using below command :

root@safesquid-swg:/var/lib/safesquid#mkdir youtube

  • Give the permission using below command :
chmod 774 youtube
chown ssquid:root youtube

root@safesquid-swg:/var/lib/safesquid# ll
total 56
drwxrwxr--   12 ssquid root  4096 Aug 29 15:35 ./
drwxr-xr-x    48 root   root  4096 Jul  4 19:06 ../
drwxrwxr--     3 ssquid root  4096 Jan 21   2019  application_signatures/
drwxrwxr--     2 ssquid root  4096 Sep  5   14:03 category/
drwxrwxr--     3 ssquid root  4096 Apr  2    18:44 content_signatures/
drwxrwxr--     2 ssquid root  4096 Jan 21   2019  imgfilter/
drwxrwxr--     3 ssquid root 12288 Sep  5  13:47 sqscan/
drwxrwxr--     3 ssquid root  4096 May 30  14:17 sscore/
drwxrwxr--     4 ssquid root  4096 Sep  5   14:03 sscore2/
drwxrwxr--     2 ssquid root  4096 Jun 13   19:12 ssqore/
drwxrwxr--     4 ssquid root  4096 Sep  5   14:03 svscan/
drwxrwxr--  2 ssquid root  4096 Aug 23 14:53 youtube/

  • Go to youtube directory using command :

root@safesquid-swg:/var/lib/safesquid#cd youtube

  • Copy YouTube API Key using WinSCP or any other tool at given path /var/lib/safesquid/youtube/

root@safesquid-swg:/var/lib/safesquid/youtube# ll
total 16
drwxrwxr--  2 ssquid root 4096 Aug 23 14:53 ./
drwxrwxr-- 12 ssquid root 4096 Aug 29 15:35 ../
-rw-rw-r--  1 ssquid root   40 Jul  3 14:11 keys
-rw-rw-r--  1 ssquid root  947 Jul  3 14:12 legends

  • After adding key, the file will look like this
root@safesquid-swg:cat /var/lib/safesquid/youtube/keys
AIz******************************o
  • After doing so, you just need to RESTART SafeSquid Service from SafeSquid Interface or by command line.
/etc/init.d/safesquid restart

Note: Please Restart SafeSquid Twice in order to Integrate YouTube API properly.

You have successfully integrated YouTube API with SafeSquid-SWG.

Now, Go ahead with Policy creation on the basis of YouTube Categories.

To do so, I will help you out in creating a simple Policy which will only allow Specific YouTube Category VIA SafeSquid all other YouTube Videos will be blocked.

YouTube API (14).PNG
YouTube API (15).PNG
YouTube API (17).PNG
YouTube API (18).PNG