Is there any way of using the YouTube API so that users can upload videos directly to my business YouTube channel? Users would grant permission to upload to my channel on the website. I want to avoid uploading to another server, then to YouTube if possible.
Thanks
You can use service account OAuth2 to authorize requests from your app on your behalf to a channel that your account is authorized to access/the owner of.
Create service account credentials: (documentation here)
and make sure the YouTube Data API v3 is enabled on your API
project (getting started guide here, if you're new to the API).
Use your service account OAuth credentials to call the upload API: (documentation here) use the auth in step 1 to upload the video your users share with you and specify your business YouTube channel ID in the video resource. Sample code in various languages here (just search for upload examples after you choose your preferred language).
Things to keep in mind:
If you enable uploads to your channel by end users but don't do any checking/validation there is potential for abuse
service account OAuth is valid for 1 year, so you'd need to refresh the service account credentials every year
It will look like these videos are being uploaded by your business channel and not other user's channels (because that's what's happening via the API).
Related
I'm trying yo create a private application that manages a YouTube account all time, not different ones for clients, only one and the client has access to create a video streaming or other functions with YouTube API v3. Only I found how to the clients logging and manage their accounts but not only one channel all time.
How i can do that?
YouTube lifetime token for a server
What you are refering to is something called service accounts. Its designed for server to server interaction. This type of autohrization is not supported by the YouTube API you need to use Oauth2.
I'm trying yo create a private application that manages a YouTube account all time, not different ones for clients, only one and the client has access to create a video streaming or other functions with YouTube API v3.
You may have some issues here. You will need to create a project on Google developer console for your application and create Oauth2 credetinals.
In order to upload videos that are public your app will need to be verified. Application verification takes time with youtube api. Make sure to apply for it early.
Only I found how to the clients logging and manage their accounts but not only one channel all time.
YouTube authorization is channel based. Your users will need to be authorized for each one of their channels. There is no way to authorize a single user to access all of their channels in one go. It has to be per channel.
I want to upload local videos into my youtube account through my web app without oAuth consent screen. I am using node js as server and react js as frontend.
You need to understand the difference between private and public data. Public data is data that is not owned by any user and is available publicly.
Methods like Search List for example access public data available on YouTube.
Private data is data that is owned by a user. In order to upload to your YouTube account you need permission to upload to that account.
The Videos.insert method as you can see by the documentation requires that the user have consented to your application accessing their YouTube account. They must have consented to your access with one of the following scopes.
So the answer to your question is that you cant. You need to consent to authorization before your application is going to be allowed to upload to YouTube
upload public videos
Please remember that all videos uploaded via the videos.insert endpoint from unverified API projects created after 28 July 2020 will be restricted to private viewing mode. To lift this restriction, each API project must undergo an audit to verify compliance with the Terms of Service. Please see the API Revision History for more details.
Your application will need to go though application verificatin process before any of the videos you upload will be public
Youtube's api ToS state that we must allow a user to upload a video to their own account or to our youtube application account. What would be the proper process for doing this? The code snippets refer to using one's own account (e.g. api key and secret key). Will these work for uploading to the user's account?
Well, if you want users to upload video on your channel, what they need is your OAuth token. This SO question also have an information about your problem.
This documentation will explain you on how to obtain an OAuth access token. It contains sample code that you can copy/follow.
For more information, you can check these tutorials:
How to Authenticate & upload videos to YouTube Channel in PHP
PHP server-side YouTube V3 OAuth API video upload guide
I have an app on the server, I need to upload some videos to one (only 1) youtube account, but without user/browser/client's interaction (I don't want an OpenID/OAuth to be shown), how can I achieve this?
I've googled, but all I ever found is always requires user interaction.
It sounds like you want to OAuth into one account (your own) to enable uploads without requiring user input. If so, you can create OAuth credentials on the Google API Console Credentials page (which I believe is the page in your screenshot) by choosing Create credentials > OAuth client ID > Web application > Create.
Once you have the client ID and client secret, you can use the process described here to generate an access and refresh token, and use these in your server code when making the API upload request.
On a side note, if you are collecting video submissions from users, YouTube recommends you have users upload to their own accounts, for a variety of reasons. See this blog post for details; in particular:
One crucial consideration is which account the videos will be uploaded
to on YouTube. It’s tempting to design a system in which all videos
are uploaded to a single “master” YouTube account, but this is always
the wrong approach. While using a master account means that each
uploader doesn’t need to register for their own YouTube account, a
high rate of uploads into a single YouTube account is a good way to
run afoul of the YouTube API’s quota system. Additionally, each
uploader to YouTube agrees to YouTube’s Terms of Service, which says
that they have the right to upload that content, and that the content
does not violate our Community Guidelines. By taking responsibility
for other users’ content, you are essentially putting your own account
and YouTube standing at risk.
I'm getting a 403 Forbidden error when trying to get youtube analytics api data using a CMS account.
Just to confirm, is a CMS account the same thing as a Service account?
I can get analytics data for channels that are owned by the oauth2 user but I get the 403 on any other channels that I have access to through my CMS account but am not the content owner of. (I have Administrator account level on the CMS account and the channels I get 403 error on have "Managed" relationship)
Question: Are there any plans to have youtube.analytics api support for querying channels managed under a CMS account?
It seems that since I can use that account to get all the analytics data for these channels using the CMS UI that I should be able to do the same using the API.
A YouTube Content Management System account is not the same thing as a Service Account. You won't get far with the YouTube APIs if you authenticate as a Service Account, since that Service Account won't have access to any actual YouTube channels. Authenticating as a CMS account, however, will give you what you want.
A lot of this recently made it into production, so let me lay out the full steps here explaining how folks with YouTube CMS access can run YouTube Analytics API reports against the channels and videos they manage.
(Optional) While authorized via OAuth 2 as the CMS account, using both the https://www.googleapis.com/auth/youtube.readonly and https://www.googleapis.com/auth/youtubepartner scopes, make a YouTube Data API v3 channels.list() call with the following parameters: part=snippet,contentDetails, managedByMe=true, maxResults=50, onBehalfOfContentOwner=CONTENT_OWNER_ID. CONTENT_OWNER_ID is the one value that you'll have to hardcode here, and it should be set to the "partner code" for your YouTube CMS account. This will give you back a list of up to 50 channels that your CMS account manages. (If you need more than 50, you'll need to page through the results.) The id of each channel will be returned in channel.id, and other useful information (like the uploads list id, if you want to get the list of videos in that channel) will also be returned.
If you already know the UC... channel id for the channel you want to run reports against, you could skip that step and go directly to the Analytics report.
To run a channel-level report on a managed channel, while authorized as the CMS account, make a YouTube Analytics API request with the following parameters: ids=contentOwner==CONTENT_OWNER_ID, filters=channel==UC..., and then any other report parameters you want.
To run a video-level report, set ids=contentOwner==CONTENT_OWNER_ID and filters=video==VIDEO_ID, where VIDEO_ID is the id of any video in any channel that the CMS account manages.
There are more details about content owner reports in the docs.