How to make calls to youtube Api with user Api key - oauth-2.0

I will be building a spring-boot app that consumes resource from the Youtube Api. However, I discovered that the youtube API has a limit of resource that can be consumed by one API key.
This will be a multi user app, So i'll like to build out the functionality in which when a user signs into the app via gmail, the user's API will automatically be used to consume resources from the youtube API , without the user having to go digging into the Youtube API documentation to get there API key.
Any ideas of how to automatically enable a new user’s api key to make the call , instead of my api key ?
Thanks in advance.

I discovered that the youtube API has a limit of resource that can be consumed by one API key.
This is called quota and its not related to the API key but rather related to the project. You have a quota limiting the number of requests that your project can make against the API. see quota calculator
This will be a multi user app, So i'll like to build out the functionality in which when a user signs into the app via gmail, the user's API will automatically be used to consume resources from the youtube API , without the user having to go digging into the Youtube API documentation to get there API key.
If you want to allow a user to login to their YouTube api account then you will be using Oauth2 client credentials and not an API key. The API key will only allow you to access public data no private data will be available.
Any ideas of how to automatically enable a new user’s api key to make the call , instead of my api key ?
API keys are not user specific you cant create a new user api key. Thats not how API keys work, api keys enable your application to access public data on YouTube it is defined by you manually though the Google developer console and identifies your application to Google.

Related

YouTube lifetime token for a server

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.

Multiple Youtube channels on 1 account. How to restrict provided API key to only 1 channel?

I need the Youtube API key from a client just to populate a link list of their recent videos.
The client expressed they have one account with multiple youtube channels attached to the one google account. For security they are asking if the API can be restricted to one youtube channel. I just fetched the data and displayed it im not a youtube API expert so i am unsure how to direct them. They want the key they provide to only allow data fetched from the specific channel? Is that possible in the API settings when creating the key?
(google search was unhelpful and the docs didnt really mention multiple channels)
Thanks for any insight.
Api keys are only able to access public data. For example public videos uploaded to youtube.
If you want to access private user data then you are going to need to use Oauth2 and authorize the user.
How you authorize the user depends upon which language you are using. You should consult the documentation Authentication
When you authorize a user then will be able to pick which channel to grant you access to. This will give you an access token that you can use to access the data on that channel.

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'

Is that possible to get youtube broadcast or livestream status without access_key

I would like to load the livestream into my live list when the status is live without using the access key.
No, it is not possible.
You need a Google Account to access the Google Developers Console, request an API key, and register your application.
Register your application with Google so that it can submit API requests.
After registering your application, select the YouTube Data API as one of the services that your application uses:
Go to the Developers Console and select the project that you just registered.
Open the API Library in the Google Developers Console. If prompted, select a project or create a new one. In the list of APIs, make sure the status is ON for the YouTube Data API v3 and, if you are a YouTube Content Partner, the YouTube Content ID API.
Source

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

Resources