问题
I'm using the API explorer at the bottom of https://developers.google.com/youtube/v3/docs/commentThreads/insert to test this call. I am requesting the scope https://www.googleapis.com/auth/youtube.force-ssl. Appreciate any help!
REQUEST:
POST https://www.googleapis.com/youtube/v3/commentThreads?part=id%2Csnippet&fields=id&key={YOUR_API_KEY}
{
"snippet": {
"topLevelComment": {
"snippet": {
"textOriginal": "comment from gdev"
}
},
"videoId": "B5BypNLbBgQ",
"channelId": "UCNqqFgLtbSjc9Er7XFv4wbA"
}
}
RESPONSE:
{
"error": {
"errors": [
{
"domain": "youtube.commentThread",
"reason": "forbidden",
"message": "The comment thread could not be created due to insufficient permissions. The request might not be properly authorized.",
"locationType": "other",
"location": "body"
}
],
"code": 403,
"message": "The comment thread could not be created due to insufficient permissions. The request might not be properly authorized."
}
}
回答1:
The video was private.... Worked fine on a public video.
回答2:
I had a similar problem. I needed to set the token in the header. the request body needs to have:
part: "snippet"
I think you also would need to set a header of:
Authorization: 'Bearer ' + access_token
回答3:
I uploaded a video and by default the comments were disabled. Once I changed to "Allow all comments" I could post via the API.
来源:https://stackoverflow.com/questions/35047038/youtube-api-comment-insert-403-forbidden-insufficient-permissions