Retrieving YouTube API v3 data for all my channels - youtube-api

I have five YouTube channels that are all under one user account (one e-mail address). I can switch between them at will within the YouTube mobile app, YT Studio and so on by using the app's Switch Account function.
I also have developed some processes that will retrieve statistics about my primary channel's videos and store them into a database.
I would like to also retrieve the same information about all my other channels, but I don't seem to be able to do this. Those processes can see only PUBLIC information about the other channels. So unlisted/private videos are skipped, for example. The simple solution would be to create credentials for the other channels of interest and apply those new credentials to the processes, but I don't see a way to create credentials for any account other than the primary on the Google Developer Console
Am I missing something about Developer Console that would allow me to create other sets of credentials for the other channels? Or maybe there's a "switch account" equivalent I'm not aware of? Or what other solution is available for multiple channels?
According to this link, this is the correct forum for my question, but Google seems to be unresponsive more often than not.

Related

How do I use the YouTube Data API to upload video to secondary channel on personal account

I have looked around Stack Overflow and seen a few posts about this but none of the solutions help.
I have a Google account which I use in YouTube. I have created a second channel on that YouTube account so that I can upload videos with a specific theme to separate them from the main videos.
Trying to use the Google API to upload the videos so that I can run it via a Python script, I keep hitting brick walls with Google who is looking for app verification, privacy policies and web page links - none of which I have.
This application is a Python script that's not available to the public and doesn't gather any public information. All I am trying to do is upload videos to my own personal YouTube account.
So I'm beginning to think it is something else I should be using rather than the API (the uploading web page isn't suitable for use in a script).
My two question are:
Can I use the YouTube API to upload a video directly to the second channel on my personal YouTube account?
Is there another simpler mechanism I should be using to upload videos via a script to my personal YouTube account? The reason I have to do it via script is that the device is unattended.
Thanks,
David
You have to acknowledge that each and every app (this to be understood in a broad sense that includes even a small script like this one from Google upload_video.py) must be verified and approved by Google prior to be able to make videos publicly available via the YouTube site.
Answer to question no. 1: yes, that is perfectly possible.
As part of the OAuth 2.0 authentication/authorization flow, you will be presented, within the browser, with the option of selecting to which account your app is to be given access rights.
You may well exercise this behavior, prior to making use of your script, with the help of Google Developers OAuth 2.0 Playground.
Upon a successful OAuth flow, you may verify (and also revoke) the permissions granted by your account on the account's permissions page.
Answer to question no. 2: no, there's no way to upload programmatically videos on YouTube that's in compliance with YouTube's DTOS, other than using the Videos.insert API endpoint.
Addendum
Since by now you have at least two credentials sets, it may be of need to know to which of your YouTube channels a given credentials object is associated.
If using the Google APIs Client Library for Python, you may easily obtain from the API the channel ID to which a given credentials object CREDENTIALS is associated by issuing a call to the Channels.list API endpoint, passing to it the parameter mine as mine=true:
from googleapiclient.discovery import build
youtube = build(
'youtube', 'v3',
credentials = CREDENTIALS)
response = youtube.channels().list(
mine = 'true',
part = 'id',
fields = 'items(id)',
maxResults = 1
).execute()
channel_id = response['items'][0]['id']
Note that the code above uses the fields request parameter for to obtain from the Channels.list endpoint only the channel's ID info (it is always good to ask from the API only the info that is of actual use).
A caveat using the above procedure is the following: if a given CREDENTIALS instance has its scopes containing only:
https://www.googleapis.com/auth/youtube.upload,
then the API will respond with an error of type insufficientPermissions and of message Request had insufficient authentication scopes.
For to invoke successfully the Channels.list it would be sufficient that the scopes attached to CREDENTIALS to include either of the one below:
https://www.googleapis.com/auth/youtube.readonly,
https://www.googleapis.com/auth/youtube.

What are the requirements for using the YouTube api to post to a specific channel?

I need to post videos to specific YouTube channels via the V3 api managed by a single account.
I am trying to use the onBehalfOfContentOwner & onBehalfOfContentOwnerChannel fields to upload the video but I'm somewhat confused about the account requirements in order to enable this.
My understanding is that it is only possible to do this with channels that are managed by a Partner Account. I have set up my account as a partner account and the next thing the documentation talks about is using a CMS account. To give permissions to manage channels. The documentation seems to suggest that a CMS account is generated automatically once you become a partner account, but I can see no sign of this.
The documentation then goes on to talk about having to have a Partner Content ID in order to get a Full CMS account. This appears to be something that you have to apply for.
Is it really necessary that the account and channels have to be set up in this way or is there an easier way to manage this?

Is it possible to host videos uploaded to my website on youtube?

I have Java based website. I would like users to log into my website and then upload videos to youtube using my youtube account. Users should not be required to have their own youtube account since videos will be uploaded using my youtube account.
Does youtube support this scenario?
If so, is there a sample code that shows me how to do this in Java?
I have used UploadVideo.java sample provided by google (https://developers.google.com/youtube/v3/code_samples/java#upload_a_video), but it requires users to log into youtube account using their id and password. That is not my use case.
Please study the terms and conditions of the Youtube service ; I think they do not allow this:
https://www.youtube.com/static?gl=GB&template=terms
YouTube accounts
4.1 In order to access some features of the Website or other elements of the Service, you will have to create a YouTube account. When
creating your account, you must provide accurate and complete
information. It is important that you must keep your YouTube account
password secure and confidential.
4.2 You must notify YouTube immediately of any breach of security or unauthorised use of your YouTube account that you become aware of.
4.3 You agree that you will be solely responsible (to YouTube, and to others) for all activity that occurs under your YouTube account.
and
5.1.L: you agree not to access Content or any reason other than your personal, non-commercial use solely as intended through and permitted
by the normal functionality of the Service, and solely for Streaming.
"Streaming" means a contemporaneous digital transmission of the
material by YouTube via the Internet to a user operated Internet
enabled device in such a manner that the data is intended for
real-time viewing and not intended to be downloaded (either
permanently or temporarily), copied, stored, or redistributed by the
user.
You can not let other people use your YouTube account/channel. The way to do is using YouTube Direct Lite
You basically add a ytdl with playlist tag while uploading videos.
You can check Android Client for how to do it in Java.
As to whether it is technically possible, yes, see https://developers.google.com/youtube/v3/guides/using_resumable_upload_protocol
The technical problem here is users will be able to delete videos too if they have your access token with full permissions. basically you need to:
load your html page with the upload interface.
add to the onclick event of the upload button to send an ajax request to a script on your server which will:
return the access token of your account to the client
soon thereafter change the access token using the refresh token
Its still technically vulnerable though. a possible solution is to obtain the access token ONLY with the scope:
https://www.googleapis.com/auth/youtube.upload
There is a very good chance it will not be vulnerable then. You should test it.

YouTube API v3 get all channels associated with a logged in user

Is it possible to get all the channels associated with a logged in user account, using youtube's version 3 API (https://developers.google.com/apis-explorer/#p/youtube/v3/).
The nearest call that I can see for YouTube.channels.list
https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list
I attempt to use this by 'Authorizing the requests using OAuth 2.0' I select part=snippet and mine=true
https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list?part=snippet&mine=true&_h=1&
but this only brings back the single channel not any of the other channels associated with the account, but the account I'm using has several channels. I need to get all channels for logged in user so I can give them the choice of what channel they are using, especially now google have messed YouTube around with the Google plus integration.
Does anybody know if this is possible?
Found the answer in YouTube's API Blog here:
http://apiblog.youtube.com/2013/06/google-page-identities-and-youtube-api.html
According to this as I'm using Android with OAuth2 there is no native Android account switcher, and
the then the API will choose the “wrong” channel in some cases, or
even no channel (e.g., if the personal account doesn’t have a
channel).
So I've got two options When this happens, the user has two options to specify the correct channel:
Use the Advanced Account Settings tool to select which channel should
be used. This is recommended when a user has one channel they want to
use for all applications.
Set up login credentials for each of their Google+ pages, and specify those > credentials, not their normal Google Account
credentials, for each application that needs access.
Both these options require the user to do something outside the boundary of the Android Application, so both solutions are not usable. Unfortunatly this piece of functionality will have to wait until Android has some better way of switching the channel for the user...
OAuth2 allows login in with only one channel, so that's not possible.
OAuth2 already gives user a choice to pick the channel they want to authorize and give access, so you don't have to implement it anyways.

Can I access to many Youtube channels reports with a only one account?

I manage several Youtube channels, each with their Gmail account and now also associated with a Google+ account.
My question is: I can access, via Youtube Analytics API, to all my Youtube channels reports with a single Google account without having to choose between them? That is, a general account with permissions to access reports on all channels.
Thanks in advance.
Yes, you actually can have these different channels linked under a single Google account.
1) Set up a Google Plus Page for your YouTube account via https://www.youtube.com/account (requires g+ account) Note: This may overwrite avatar and channel title, and may change your YouTube display name to whatever you set your Page Title to be.
2) Your personal g+ account will be the owner of this Google plus page.
3) Repeat for other accounts, setting up their own google plus pages.
4) You can add your main personal g+ account (if you have one for each unique gmail) as a "manager" of these other pages, giving a single login access to the pages (and therefore all the associated YouTube accounts) via the drop down "switch acocunts" on YouTube (top right drop down)
5) After a page is old enough (2 weeks?) you can change owners so your main g+ page owns the page. Not necessary but helps consolidate + lets you abandon other personal g+ accounts.
Let me know if you're able to follow that. There are benefits to doing this with only a single channel. You won't be able to see "combined" analytics but you can switch accounts much, much easier.
This link provides the youtube channel report in range. But when used with google php library it get hooked in a "User login required Error!"
https://developers.google.com/apis-explorer/#p/youtubeAnalytics/v1/youtubeAnalytics.reports.query?ids=channel%253D%253DMINE&start-date=2014-05-01&end-date=2014-06-30&metrics=views&dimensions=day&_h=3&
Is there any way i can access the channel analytics report in youtube V3 same as like in v3
http://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list?part=statistics&id=UCMGgBRBiijmpgL3xNuiDVOQ&_h=10&

Resources