I am building a web application that needs to upload videos on Youtube via code. I know I can log into Google by using the following button:
<google-sign-in-button button-id="uniqueid" options="options"></google-sign-in-button>
together with:
<meta name="google-signin-client_id" content="CLIENT_ID.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script>
(as stated in https://developers.google.com/identity/sign-in/web/sign-in ) and then upload the video (as explained in https://developers.google.com/youtube/v3/code_samples/javascript#authorizing_requests ).
The context is:
- I have a videos manager in my application.
- These videos might be uploaded to a Youtube channel by an administrator.
The problem is:
- The administrator might be logged into their Google account while using the application.
- The videos must be uploaded to an account different from the administrator's.
Question:
Is there a way to specify in the code a specific Youtube account so that the videos are uploaded to that account's Youtube channel?
I don't know whether it is better to solve this by using javascript or Nodejs, so any tip is welcome.
Edit:
According to KEndi's answer, I am using this call to perform the insert function:
Youtube.videos.insert({
resource: {
snippet: {
title: "Testing YoutTube API NodeJS module",
description: "Test video upload via YouTube API"
},
status: {
privacyStatus: "private"
}
},
part: "snippet,status",
media: {
body: fs.createReadStream("video.mp4")
},
onBehalfOfContentOwner: CONTENT_OWNER_ID,
onBehalfOfContentOwnerChannel: CONTENT_OWNER_CHANNEL
}, (err, data) => {
if(err) { return lien.end(err, 400);}
lien.end(data);
});
However, I get this error:
Error: The specified content owner account was not found. at Request._callback (...)
And when I try the API through this link: https://developers.google.com/youtube/v3/docs/videos/list?hl=es-419 specifying the "onBehalfOfContentOwner" parameter, the response i get is:
{ "error": { "errors": [ {
"domain": "youtube.parameter",
"reason": "contentOwnerAccountNotFound",
"message": "The specified content owner account was not found.",
"locationType": "parameter",
"location": "onBehalfOfContentOwner" } ], "code": 404, "message": "The specified content owner account was not found." } }