I am using the Youtube Data API to insert a video.
The I use the API to insert a "commentThread" to the video, as described here in the doc. Here is my code:
import { google } from "googleapis"; const googleApiClient = new google.auth.OAuth2( GOOGLE_CLIENT_SECRET.web.client_id, GOOGLE_CLIENT_SECRET.web.client_secret, GOOGLE_CLIENT_SECRET.web.redirect_uris[0] ); googleApiClient.credentials = tokens; google.options({ auth: googleApiClient }); const apiYoutube = google.youtube({ version: "v3" }); await apiYoutube.commentThreads.insert({ part: ["snippet"], requestBody: { snippet: { videoId, topLevelComment: { snippet: { textOriginal: "Hello world!", }, }, }, }, });Depending on the video visibility, the response differs:
- if visibility is "private", I get a 403 error:
{ message: 'The comment thread could not be created due to insufficient permissions. The request might not be properly authorized.', domain: 'youtube.commentThread', reason: 'forbidden', location: 'body', locationType: 'other'}I am positive that my access token (acquired through an oauth2 process) has the correct scope: "https://www.googleapis.com/auth/youtube.force-ssl"
- if visibility is "public" or "unlisted", I get a 400 error:
{ message: 'This action is not available for the item.', domain: 'youtube.mfk', reason: 'mfkWrite'}In the youtube console, in Settings > Upload defaults > Avanced settings > comments, it is set to "Hold potentially inappropriate comments for review". I have also tried "Allow all comments".
How can I fix this issue and publish comments to my video?
I am aware of this similar question and tried the various suggestions but it still does not work and the API may have evolved.