YouTube API Integration With SafeSquid To Allow Specific YouTube Videos

YouTube API Integration With SafeSquid To Allow Specific YouTube Videos

Overview

YouTube is a video-sharing website which provides a wide variety of videos. YouTube video content categories organize channels and videos on YouTube website. YouTube has lots of videos for entertainment like comedy, music, movies, web series, sports, etc. YouTube also provides lots of educational and training content used by students, employees, faculties, etc. in day-to-day life. 
In every organization YouTube video should be used for Productive purposes like learning, Marketing, etc. YouTube’s recommendations become confused over time, and begin showing you irrelevant or useless content. Watching unnecessary YouTube videos without any restriction, reduces work productivity and increases bandwidth utilization. 
Restriction on watching unnecessary YouTube Videos will save lots of productive time and internet bandwidth. You can restrict unwanted videos from YouTube site on the basis of the video category. To identify the category of any video YouTube provides YouTube API.
SafeSquid SWG integrates with YouTube API which is used to identify the Category of the Requested YouTube Video. YouTube Video categories are enumerated in SafeSquid SWG. Now policies can be created on the basis of these 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.All the
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/channels etc.
Of course, all the videos/Playlist/channel etc. are educational and knowledge sharing.
But he faces some difficulty for extracting Channel-ID and List-ID of the requested playlist/channel regularly.
SafeSquid SWG has given them the fantastic 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.
Find category to allow or block Youtube video 

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 Link
Create a Youtube V3 API using google account for Youtube API integration with safesquid 
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

Click on select a project to integrate Youtube API with safesquid 
Click on project to integrate Youtube API with safesquid

NAME AS: YouTubeAPI-For-SafeSquid

Name and create a project to integrate Youtube API with safesquid 

SELECT A PROJECT

Select a project to integrate Youtube API with safesquid 
Get a access of API Library
Select YOUTUBE DATA API V3  to integrate Youtube API with safesquid 

ENABLE YOUTUBE DATA API V3

ENABLE YOUTUBE DATA API V3 to 

CREATE CREDENTIALS

Select a Create credentials to integrate Youtube API with safesquid 
Click on Create credentials to integrate Youtube API with safesquid

SELECT API KEY

select API key to create API keys  
Google generate Youtube API keys

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:
  1. root@safesquid-swg:/var/lib/safesquid#cd /var/lib/safesquid/Create the directory using below command:
  2. root@safesquid-swg:/var/lib/safesquid#mkdir youtube
Give the permission using below command:
  1. chmod 774 youtube
  2. chown ssquid:root youtube
  3. root@safesquid-swg:/var/lib/safesquidll
  4. total 56
  5. drwxrwxr--   12 ssquid root  4096 Aug 29 15:35 ./
  6. drwxr-xr-x    48 root   root  4096 Jul  4 19:06 ../
  7. drwxrwxr--     3 ssquid root  4096 Jan 21   2019  application_signatures/
  8. drwxrwxr--     2 ssquid root  4096 Sep  5   14:03 category/
  9. drwxrwxr--     3 ssquid root  4096 Apr  2    18:44 content_signatures/
  10. drwxrwxr--     2 ssquid root  4096 Jan 21   2019  imgfilter/
  11. drwxrwxr--     3 ssquid root 12288 Sep  5  13:47 sqscan/
  12. drwxrwxr--     3 ssquid root  4096 May 30  14:17 sscore/
  13. drwxrwxr--     4 ssquid root  4096 Sep  5   14:03 sscore2/
  14. drwxrwxr--     2 ssquid root  4096 Jun 13   19:12 ssqore/
  15. drwxrwxr--     4 ssquid root  4096 Sep  5   14:03 svscan/
  16. drwxrwxr--  2 ssquid root  4096 Aug 23 14:53 youtube/
  17. Go to youtube directory using command:
  18. root@safesquid-swg:/var/lib/safesquid#cd youtube
  19. Copy YouTube API Key using WinSCP or any other tool at given path /var/lib/safesquid/youtube/
  20. root@safesquid-swg:/var/lib/safesquid/youtubell
  21. total 16
  22. drwxrwxr--  2 ssquid root 4096 Aug 23 14:53 ./
  23. drwxrwxr-- 12 ssquid root 4096 Aug 29 15:35 ../
  24. -rw-rw-r--  1 ssquid root   40 Jul  3 14:11 keys
  25. -rw-rw-r--  1 ssquid root  947 Jul  3 14:12 legends
After adding key, the file will look like this
  1. root@safesquid-swg:cat /var/lib/safesquid/youtube/keys
  2. AIz******************************o
After doing so, you just need to RESTART SafeSquid Service from SafeSquid Interface or by command line.
  1. /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.
Click on configure to  integrate Youtube API with safesquid 
Policy to integrate Youtube API with safesquid
Youtube Video policy to allow specific video 
Youtube Video policy to allow specific video


    • Related Articles

    • Allow Specific YouTube Channel and its Playlist

      Client Scenario Ganpat University provides graduate programs to various colleges. Ganpat University distributes internet to their students. Ganpat University want to block entire www.youtube.com for their students, but wants some of the YouTube ...
    • Block Specific Youtube Channel

      Overview Prevent users to access specific YouTube Channel like 'T-Series'. Note: Blocking of Specific YouTube channel and allowing all the other YouTube videos is a hypothetical scenario. YouTube website is not designed for such hypothetical ...
    • Allow specific website through SafeSquid

      Client Scenario Stark tech is having 200 employees. Stark tech distributes all 200 employees into different 'User Groups'. Now Stark tech blocked all the websites for defined 'User Group' say 'General Users' Stark tech challenges are: General users ...
    • How to allow specific website through category

      Client Scenario Stark tech is having 200 employees. Stark tech distributes all 200 employees into different 'User Groups'. Now Stark tech blocked all the websites for defined 'User Group' say 'General Users' Stark tech challenges are: General users ...
    • Allow anydesk

      Overview For security reasons you blocked all the traffic to all users. But some of the users in your network need to access remote applications. Using SafeSquid you can allow specific users in your network to access remote applications. How it ...