Accessing YouTube Data APi v2 - youtube

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).

Related

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'

YouTube API from V2 to V3 migration

I'm still using old V2 api and now i get https://youtube.com/devicesupport.
My current request is:
https://gdata.youtube.com/feeds/api/users/{username}/uploads?alt=jsonc&max-results=15&v=2
There is no authentication required to make that call
Question:
Any idea how to achieve the same with new Google V3 API? I check documentation but didn't found answer for that.
I had the same problem with V3 api. I think you can't access videos informations without authentication anymore, but you don't need to use an OAuth to get a snippet from some video or search. I was searching a simple solution for my app, because I just want to request title, thumb and descriptions.
The new url will be:
https://www.googleapis.com/youtube/v3/videosid={VIDEO_ID}&part=snippet&key={YOU_API_KEY}
You need to access google developers console, enable youtube api and your public access key - on credentials (API KEY), so they can relate your app to all requests.
And I found this example in PHP if you need to parse JSON result:
http://www.leenooks.com/php/parsing-youtube-v3-json-with-php-examples.html
I'm still don't know all the limitations of V3, I was using V2 too, but maybe for uploads, or more control for youtube accounts you'll have to use OAuth.
I hope this will help you.

How to get Youtube video json list under an user via Google V3 API

In V2, I can use: http://gdata.youtube.com/feeds/api/videos/?alt=json&author=XXX
However, V2 has been deprecated and can not be used anymore.
What's the correct replacement in Google API V3?
You should get your API key (for server or for client).
http://code.google.com/apis/console#access
And use https://www.googleapis.com/youtube/v3/search?part=snippet&channelId={CHANNEL_ID}&key={YOUR_API_KEY}
https://developers.google.com/youtube/v3/docs/search/list
But, there are some bug reports about this API now.
https://code.google.com/p/gdata-issues/issues/detail?id=6598
https://code.google.com/p/gdata-issues/issues/detail?id=6599
https://code.google.com/p/gdata-issues/issues/detail?id=6600

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

Should I stop using google API V2?

I have an application for my client that uploads videos on youtube on behalf of my client.
What my client do is provide his user name and password in my app and then app uploads videos using Youtube DATA API V2(Username/password credentials).
But since username/password authentication mechanism is not available in V3, I have to change the user involvement that is required in the new Authorization mechanism. But my client is does not agree.
The question is, what if I continue to use API V2 and not switch to V3. Is there any chance that Google will stop V2 and I have to move to V3?
Is there any way I keep authenticating using credentials and not switch to OAuth 2.0?
You asked: Is there any chance that google will stop V2 and I have to move to V3?
Short answer: You need to switch to YouTube's v3 API.
From Google:
The YouTube Data API (v2) has been officially deprecated as of March 4, 2014. Please refer to our deprecation policy for more information. Please use the YouTube Data API (v3) for new integrations and migrate applications still using the v2 API to the v3 API as well.
If you haven’t yet migrated from the previous API version (v2), we wanted to remind you it will be unsupported as of April 20, 2015, and shut down soon thereafter. To make it fast and easy for you to migrate, check out the new Migration Guide. It’ll help you identify the v3 API methods and parameters that correspond to the functionality that you've been using in the v2 API. It also points out new features that the v3 API supports.
Source
Your second question: Is there any way I keep authenticating using credentials and not switch to OAuth 2.0? I do not know the answer to. Maybe ask as a separate question?

Resources