Youtube Reporting API OAuth in Azure Data Factory - oauth-2.0

Hi guys i'm pretty new to Azure Data Factory and i'm implementing a pipeline to retrieve stats about a YouTube channel through API and storing them in a SQL Database in order to connect it to some BI services.
Using Youtube DATA API i was able to:
retrieve all the videos uploaded in the channel - API Data - PlaylistItems
some summarized stats for each one API Data - Videos - with part:statistics
The next thing i'd like to do is retrieve detailed stats for each video on a monthly basis, i was able to do this with Google Apps Script on a Google Sheets using the Youtube Analytics and Reporting API API Call Reference
In Azure Data Factory i'm struggling with the Google OAuth, the Youtube DATA API supported the API Key authentication and that was pretty easy.
Instead the Youtube Analytics and Reporting API requires the OAuth and do not support services account so the only option i believe is the server-side flow Google OAuth server side flow
I believe is possible to do, in this link a user struggled with the JSON output of these API in Data Factory - 5
Do you think it is feasible and i'm going in the right direction?
Really appreciate any help!
Thanks

Related

Does YouTube Data API billing change if the APIs are called from GCP server or AWS server?

I'm building an Android app which embeds YouTube videos. I'm confused on how the billing works for the YouTube Data API v3. Is it dependent on whether the APIs are called from GCP server or AWS server?
The YouTube Data API, is a free API Google does not charge you for accessing this API. You are free to use it. Therefore no billing account is needed in order to access this API.
You do have a quota which limits the number of request that you can make to the API over a period of time.
Useful links
Quota cost calculator
YouTube API and cost based quota demystified

Read data from Youtube Analytics API without Oauth2

I am currently writing a python script to pull information from YouTube Analytics API for a list of separate YouTube channels. The output would be, for example, count video views for each YouTube channel in last month.
My initial idea was to ask each of the YouTube account owners to create a YouTube Analytics app in their console.cloud.google, create a Project, enable the youTube Analytics API, generate an API key and specify that it is needed for the YouTube Analytics API.
I'm testing with one account and if I try to run the script using the API Key generated with the process described above and authenticating like this:
def get_service():
return build('youtubeAnalytics', 'v2', developerKey=API_KEY)
it fails with a HttpError 401 Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
I am not sure if I have done something wrong in creating the API key, or if instead the YouTube Analytics API requires Oauth2 authentication. If the latter is the case, then I am surprised that google console lets you to go all the way and generate API keys and specify that they are needed for the YouTube Analytics API, only for you to find out that you can't use it.
So my question is: do I have to use Oauth2 for YouTube Analytics API or can I use the API key? I'm trying to read data from "my own" account, so why do I need to manually authorise my own app?
Ok I found out that it is not possible to use YouTube Analytics API without OAuth 2.0 authentication. The Google docs and the Google console are very confusing in my opinion as they respectively allow you to create API keys specific for YouTube Analytics API and describe API keys as a possible way to authenticate (only to tell you after that, that all methods require OAuth2.0).
I'm still unclear on how to setup YouTube Analytics API authentication for a command-line python script that does not require users to give manually consent every time the script runs.
I will open a separate question for that.
Set key parameter. You can read data with api key. It's simple.
http -v 'https://www.googleapis.com/youtube/v3/playlistItems?playlistId={playlistId}&part=id,snippet,contentDetails,status&key={api_key}&max_results=10'

How to get Youtube video views by date range

I am trying to get youtube video views by date range and it is working fine with oAuth. But I am using cron script to collect those data through service account, when I try to execute the script it says:
Error calling GET https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DUC88Bq63MDJi9szYPEGfv7YA&start-date=2014-02-01&end-date=2016-06-29&metrics=views:
(400) Invalid query. Query did not conform to the expectations".
Could you please help me anyone to resolve this issue. Thanks in advance.
Using service account is not supported by Youtube Analytics and Reporting API
The service account flow supports server-to-server interactions that do not access user information. However, the YouTube Reporting API and YouTube Analytics API do not support this flow. Since there is no way to link a Service Account to a YouTube account, attempts to authorize requests with this flow will generate an error.
Unfortunately, you need to do OAuth2 to get your report.
Resources you can check for information:
Youtube Analytics API PHP Invalid query. Query did not conform to the expectations
Implement OAuth 2.0 Authorization

Get YouTube playlist videos anonymously

I would like to display a list of videos from a YouTube playlist in an intranet application.
Is it possible to get the list of videos from a YouTube playlist using the Data api (or any other way) without requiring the user to login?
Everything that I have read so far in the YouTube data api requires the user to be signed in to authenticate.
unfortunately, you can't access youtube data API with anonymously user.
Your application must have authorization credentials to be able to use the YouTube Data API.
The Developers Console associates your credentials with the APIs that you indicate that your application will use. Note that the Developers Console does not allow you to select the YouTube Data API (v2). However, authorization credentials for the v3 API will also work for the v2 API.
If possible, you should actually use YouTube Data API (v3) rather than the v2 API in your application. The YouTube API blog explains some of the benefits that the newer API offers, and we have added a year's worth of additional functionality to the API since that blog post!
related link : https://developers.google.com/youtube/2.0/developers_guide_protocol_oauth2#OAuth2_Client_Side_Web_Applications_Flow

Accessing YouTube Data APi v2

When choosing APIs to access in the "Services" tab of the Google APIs Console, the only YouTube APIs listed are "YouTube Data API v3" and "YouTube Analytics API".
Does accessing the data api v3 allow me access to v2 as well? I need to use the comment functionality since I don't believe it's in v3.
Thanks!
For v2 of the data API, you'll still need to create a client ID/secret in the API console to do oAuth2 authentication, but when it comes to simple data calls, rather than getting an API key from that same console you will instead have to register your app and get an older developer key from the YouTube dashboard; you can do so here:
https://code.google.com/apis/youtube/dashboard
(also, you are correct that comments are not yet part of the v3 data API, so using v2 is the supported method to interact with that info).

Resources