Youtube Comment API: Comment Insert 403 forbidden insufficient permissions - youtube-api

This is what im using to add comments to youtube :
gapi.client.youtube.commentThreads.insert({
part: "snippet", commentData
}).then(function (response) {
console.log("response", response);
})
This is what im getting while hit that :
{
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission: Request had insufficient authentication scopes."
}
],
"code": 403,
"message": "Insufficient Permission: Request had insufficient authentication scopes."
}
}

Insufficient Permission: Request had insufficient authentication scopes.
Means exactly that the currently authenticated user has not granted you the permissions to do that.
If you check the documentation comments.insert you will see that in order to use this method you must have authncated your user with the https://www.googleapis.com/auth/youtube.force-ssl scope

Related

Unable to fetch data from YT monetisation metrics api endpoint

When we are are trying to fetch data from youtube monetisation metrics api endpoint for an account, but it is providing us with a** forbidden error**. We have also checked for monetaryanalytics scope for that account and it is available in account-props.
We have been receiving a forbidden error without any other error message to act further upon it
Adding the API response here:
{
"error": {
"code": 403,
"message": "Forbidden",
"errors": [
{
"message": "Forbidden",
"domain": "global",
"reason": "forbidden"
}
]
}
}
Can anyone please help on this, any help will be appreciated

Unable to fetch YouTube Insights for some accounts

For specific accounts, we are able to fetch data but not able to fetch reporting analytics, I am getting
error { "error": {
"code": 403,
"message": "Forbidden",
"errors": [
{
"message": "Forbidden",
"domain": "global",
"reason": "forbidden"
}
] } }
Account has permissions for accessing reports. But for accounts with same permissions, we are able to fetch insights
API Endpoint: https://youtubeanalytics.googleapis.com/v2/reports
API Request:
https://youtubeanalytics.googleapis.com/v2/reports?access_token=xxxxxxx&dimensions=day&metrics=views%2CredViews%2Ccomments%2Clikes%2Cdislikes%2CvideosAddedToPlaylists%2CvideosRemovedFromPlaylists%2Cshares%2CestimatedMinutesWatched%2CestimatedRedMinutesWatched%2CaverageViewDuration%2CaverageViewPercentage%2CannotationClickThroughRate%2CannotationCloseRate%2CannotationImpressions%2CannotationClickableImpressions%2CannotationClosableImpressions%2CannotationClicks%2CannotationCloses%2CcardClickRate%2CcardTeaserClickRate%2CcardImpressions%2CcardTeaserImpressions%2CcardClicks%2CcardTeaserClicks%2CsubscribersGained%2CsubscribersLost%2CestimatedRevenue%2CestimatedAdRevenue%2CgrossRevenue%2CestimatedRedPartnerRevenue%2CmonetizedPlaybacks%2CplaybackBasedCpm%2CadImpressions%2Ccpm&ids=channel%3D%3DMINE&startDate=2020-06-10&endDate=2020-07-09

YouTube API V3 Comment Threads doesn't work with access Token

I am trying to call the following url with my access token which is for getting comments from a video but it doesn't seem to work and gives me a Insufficient Permissions Error.
Here's the URL I try to call-
https://www.googleapis.com/youtube/v3/commentThreads?part=snippet&maxResults=1&videoId=tdUX3ypDVwI&access_token={myAccessToken}
but it sends me the following error:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission"
}
],
"code": 403,
"message": "Insufficient Permission"
}
}
Apparently, It doesn't make sense to me? Please help.
You need the following scope :
https://www.googleapis.com/auth/youtube.force-ssl

Cannot delete comment on Youtube video via API

I'm trying to delete followiing comment z12mdhjgxrfgtpf3d231jrz5vo3jdj0lo on this video but the response code is 400. I'm using token of the channel's admin with https://www.googleapis.com/auth/youtube.force-ssl scope as it required by documentation.
The request is:
DELETE https://www.googleapis.com/youtube/v3/comments?id=z12mdhjgxrfgtpf3d231jrz5vo3jdj0lo&alt=json
{
"query_params": {
"id": "z12mdhjgxrfgtpf3d231jrz5vo3jdj0lo",
"alt": "json"
}
}
The response:
{
"error": {
"errors": [
{
"domain": "youtube.comment",
"reason": "processingFailure",
"message": "The API server failed to successfully process the request. While this can be a transient error, it usually indicates that the requests input is invalid.",
"locationType": "parameter",
"location": "id"
}
],
"code": 400,
"message": "The API server failed to successfully process the request. While this can be a transient error, it usually indicates that the requests input is invalid."
}
}
What is wrong with the request?
That's token debug info:
{
issued_to: "493985796851.apps.googleusercontent.com",
audience: "493985796851.apps.googleusercontent.com",
user_id: "109704411339866376304",
scope: "https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/youtube.force-ssl https://www.googleapis.com/auth/youtube.upload",
expires_in: 2452,
access_type: "offline"
}
The reason you're not able to delete the comment is that you're using Comments.delete to remove comment which was written by other users . Comments.delete only deletes your own comments in your video.
To delete comment of other users, use Comments.setModerationStatus and set moderationStatus to "rejected".
So just repeat what you did but this time using Comments.setModerationStatus. There's a Try-it in the link for testing purposes.

YouTube Data API: 403 forbidden error when accessing videos endpoint

When I try to request infos about a video via the YouTube Data API, I always get a 403 forbidden error:
https://www.googleapis.com/youtube/v3/videos?id={video_id}&key={my_key}&part=snippet,contentDetails,statistics,status,fileDetails
Error message:
{
"error": {
"errors": [
{
"domain": "youtube.common",
"reason": "forbidden",
"message": "Forbidden"
}
],
"code": 403,
"message": "Forbidden"
}
}
I have not restricted any referrers for my key, and the key is valid. Does anybody now why this is not working? I think I sticked to the docs at
https://developers.google.com/youtube/v3/docs/videos/list#try-it
If I omit the fileDetails part, the request resolves fine. Thanks in advance!

Resources