Youtube API quota exceeded with 1 video - youtube

I try to insert a video in nodeJS to Youtube, and I got this error :
{ errors: [ { domain: 'youtube.quota',
reason: 'quotaExceeded',
message: 'The request cannot be completed because you have exceeded your quota.'
} ], code: 403, message: 'The request cannot be completed because
you have exceeded your quota.' }
EDIT : this is when I use Auth with an existing Token, I get token from https://developers.google.com/oauthplayground/ and use it in my code. I tried with different accounts, can't upload video but I can insert item in playlist for example.
Here is my code (nodeJS) :
var req = Youtube.videos.insert({
"resource": {
// Video title and description
"snippet": {
"title": "Test",
"description": "Test video upload via YouTube API"
},
"status": {
"privacyStatus": "private"
}
},
"part": "snippet,status,id",
"media": {
"body": fs.createReadStream('./test.mp4')
}
}, function (err, data) {
....
The video is 600 Ko... How can I see or update quotas ? I use OAuth auth, for example I can insert elements in my playlist with no problems, but I can't upload videos. Do I need something ?
Thanks.

Here is a reference of your error from the documentation.
About the quota:
The YouTube Data API uses a quota to ensure that developers use the
service as intended and do not create applications that unfairly
reduce service quality or limit access for others. All API requests,
including invalid requests, incur at least a one-point quota cost. You
can find the quota available to your application in the Developers
Console.
Projects that enable the YouTube Data API have a default quota
allocation of 1 million units per day, an amount sufficient for the
overwhelming majority of our API users. Default quota, which is
subject to change, helps us optimize quota allocations and scale our
infrastructure in a way that is more meaningful to our API users. You
can see your quota usage on the Usage tab for the API in the
Google Developer's Console.
Note: If you reach the quota limit, you can request additional quota on the Quotas tab in the Developer's Console.

Related

Using RSC To Access Chat Messages with Microsoft Graph

I am building a Teams chat-bot that looks at the history of messages in the current chat/channel whilst in conversation with the user.
My bot has been granted all the RSC (Resource-Specific Content) Permissions it needs (see image below)
Here is the relevant parts of the manifest:
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.11/MicrosoftTeams.schema.json",
"version": "1.0.0",
"manifestVersion": "1.11",
"id": "bd33f8b1-b593-433c-926e-44a27c1bd94a",
...
"permissions": [
"identity",
"messageTeamMembers"
],
...
"bots": [
{
"botId": "e6d93739-a8ab-412d-a4f6-b6f514a3451a",
"scopes": [
"team",
"personal",
"groupchat"
],
"isNotificationOnly": false,
"supportsFiles": true
}
],
"validDomains": [],
"webApplicationInfo": {
"id": "e6d93739-a8ab-412d-a4f6-b6f514a3451a",
"resource": "https://RscBasedStoreApp",
"applicationPermissions": [
"TeamSettings.Read.Group",
"ChannelMessage.Read.Group",
"TeamSettings.Edit.Group",
"ChannelSettings.ReadWrite.Group",
"Channel.Create.Group",
"Channel.Delete.Group",
"TeamsApp.Read.Group",
"TeamsTab.Read.Group",
"TeamsTab.Create.Group",
"TeamsTab.ReadWrite.Group",
"TeamsTab.Delete.Group",
"Member.Read.Group",
"Owner.Read.Group",
"ChatSettings.Read.Chat",
"ChatSettings.ReadWrite.Chat",
"ChatMessage.Read.Chat",
"ChatMember.Read.Chat",
"Chat.Manage.Chat",
"TeamsTab.Read.Chat",
"TeamsTab.Create.Chat",
"TeamsTab.Delete.Chat",
"TeamsTab.ReadWrite.Chat",
"TeamsAppInstallation.Read.Chat",
"OnlineMeeting.ReadBasic.Chat",
"Calls.AccessMedia.Chat",
"Calls.JoinGroupCalls.Chat",
"TeamsActivity.Send.Chat"
]
}
}
Note: the bot has permission to read messages in chats and channels. Specifically, my problem affects chats and not channels (which I can get messages from fine).
In order to do this, I get a JWT token for the bot account, accessing the Graph API like so:
GraphServiceClient<?> gsc = GraphServiceClient.builder()
.authenticationProvider(u -> mac.getToken())
.buildClient();
Next, I am using the Graph API to pull back these messages. For messages in channels I can do:
gsc.teams("some group id")
.channels("team id")
.messages()
.buildRequest(Collections.emptyList()).get()));
This works fine.
For chats, I am doing something like:
gsc.chats("29:13qY8hmfkJinH9-v7rYKjCNFHYFJXKbjqR-NyzyKzL694npelHJoq5HrVtqJLRYo79OYeHGQq-bhtJM5N-yKXyQ")
.messages()
.buildRequest().get()));
However, this time I get an error from the Graph API:
[Some information was truncated for brevity, enable debug logging for
more details] com.microsoft.graph.http.GraphServiceException: Error
code: Forbidden Error message: Invoked API requires Protected API
access in application-only context when not using Resource Specific
Consent. Visit
https://learn.microsoft.com/en-us/graph/teams-protected-apis for more
details.
GET
https://graph.microsoft.com/v1.0/chats/29:13qY8hmfkJinH9-v7rYKjCNFHYFJXKbjqR-NyzyKzL694npelHJoq5HrVtqJLRYo79OYeHGQq-bhtJM5N-yKXyQ/messages
SdkVersion : graph-java/v5.6.0
I am at a loss to explain why querying channels works fine but querying chats fails.
Any help gratefully appreciated!
This is a protected API and in order to use it you will first need to make a formal request to Microsoft Graph, asking for permissions to use the API without any user interaction
Here is the list of protected APIs. You need to fill this form to get the required permissions.
To request access to these protected APIs, complete the following
request form. We review access requests every Wednesday and deploy
approvals every Friday, except during major holiday weeks in the U.S.
Submissions during those weeks will be processed the following
non-holiday week.
The other option would be to use delegated flow.

YouTube API: detect that the video is age-restricted

As per docs:
contentDetails.contentRating.ytRating
A rating that YouTube uses to identify age-restricted content.
But that doesn't seem to work as documented, here's the example: https://www.youtube.com/watch?v=IUc0wyae-WI
API response:
{
"items": [
{
"id": "U9x_WdDwATA",
"contentDetails": {
"contentRating": {},
},
}
]
}
Notice that contentRating.ytRating isn't set which means that the video doesn't have age-restriction according to API.
But actually it's not the case: https://www.youtube.com/embed/IUc0wyae-WI?hl=en
This video is age-restricted and only available on YouTube. Learn more
Watch on YouTube
Where's my mistake? Or is it the bug in YouTube API v3?
try to find playabilityStatus:
see for more details:
Use the YouTube API to check if a video is embeddable
This is undocumented API existing for long time, so exploring it is up
to developer. I am aware of "status" (ok/fail), "errorcode" (100 and
150 in my practice), "reason" (string description of error). I am
getting duration ("length_seconds") this way because oEmbed does not
provide this information (strange, but true) and I can hardly motivate
every employer to get keys from youTube to use official API

How can I solve Video Rating Disabled?

I'm doing a project using the YouTube Data API's Videos.rate endpoint.
And I got some problems: some particular minor channels (e.g. my client's channel) are sending error messages:
{
"error": {
"code": 403,
"message": "The owner of the video that you are trying to rate has disabled ratings for that video.",
"errors": [
{
"message": "The owner of the video that you are trying to rate has disabled ratings for that video.",
"domain": "youtube.video",
"reason": "videoRatingDisabled",
"location": "id",
"locationType": "parameter"
}
]
}
My boss wants to help them to solve that problem, but I don't know how to solve this at all. There is no problem with other major channels with 1M+ subscriptions.
I did my best to google this problem, yet couldn't find good results until now.
Before rating the video, check if the vide has enabled the rating.
I can't test right now, but, and idea could be:
Use getRating and check the items[].rating value - if the result is none or unspecified, then, you have to handle your logic for make them know that this video can't be rated - due its owner disabled rating their video.
The message you show in your question says that you cannot rate that video because the owner doesn't allow it. YouTube Data API wont bypass such restriction and there's not much that can be done further.
Ask your boss (or the owner of the video) about allow rating their video(s) and then verify if the video can be rated, if so, try again rate the video.

Simplest way to display upcoming events from a public Google calendar?

I have a public calendar on the site. I need to display upcoming events on the front page.
After spending the whole day on this I am about to give up. Google is disabling older API there is no documentation or anything. I am parsing the RSS feed:
http://www.google.com/calendar/feeds/.../public/basic?futureevents=true
And grabbing feed/entry/update and feed/entry/title from XML. I read somewhere that futureevents will display upcoming events. However I get the list of older events.
Okay, then I tried to use API V3 https://developers.google.com/google-apps/calendar/v3/reference/events/list
Here is the responce I get:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
}
I jumped through more hoops and installed their ruby code sample as I need this for Rails site.
It sort of worked but it requires user to confirm access to their own calendar. I don't need that. Plus it seems that authentication only valid for a day.
The said calendar is public. It is being displayed in iframe on the site with xml and ical feed. All I need is to parse upcoming events to show them on front page.
What is the way to do it without authorization and other ridiculous stuff?
//This works for me! js:
var request = gapi.client.calendar.events.list({
'calendarId': 'xxx',
'timeMin': (new Date()).toISOString(),
'showDeleted': false,
'singleEvents': true,
'maxResults': 1,
'orderBy': 'startTime'
});
request.execute(function(resp) {}
Use this wizard to create a new API project: https://console.developers.google.com/start/api?id=calendar Then click on "create new key" (choose server key). Then do a request to https://www.googleapis.com/calendar/v3/calendars//events?key={YOUR_API_KEY} replacing the email and api key with your values.

Quota Limits For You-Tube Data API V3?

The new Google Developers console shows the following limit for YouTube Data API v3:
PER USER LIMIT 2 requests/second/user
Whereas the old Google Developers console shows:
2.0 units/second/user
(i.e. one is requests per second, the other is units per second which are quite different).
From - https://developers.google.com/youtube/v3/determine_quota_cost - the Search request appears to have a cost of 200 units, if the latter case above is correct would this mean we can only make one of these requests every 100 seconds?
This does seem to tie in more closely with what we are experiencing which is regular occurrences of the following 403 forbidden error after paging through only a few results from a YouTube search:
"error": {
"errors": [
{
"domain": "youtube.quota",
"reason": "quotaExceeded",
"message": "Quota Exceeded"
}
],
"code": 403,
"message": "Quota Exceeded"
}
}
The new console is right on this point. It's request/sec.
But you may have been hitting daily quota limits.
Remember that in many cases, you can substitute a less costly call, such as youtube.videos.list, in place of the youtube.search.list method. For example, to search most popular videos instead of the search.list call, you can use the videos.list call using the most popular chart.
you can contact youtube and apply for higher quota or pay for higher quota

Resources