1

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."  } }
chopeds
  • 287
  • 1
  • 5
  • 21
  • To answer your question, you can set channelId= and channelTitle= on the code. – Felipe Lopez Dec 14 '16 at 05:31
  • 1
    First of all, thanks for your answer @FelipeLopez. However, what I want to do is to program an upload to a Youtube account with username = "username1" and password = "pswd1" from an explorer where an administrator is logged into Google with their own account (username = "username2" and password = "pswd2") without having to logout from their own google account. Are you sure your answer will work? – chopeds Dec 14 '16 at 08:54
  • Try to check this [`videos:insert`](https://developers.google.com/youtube/v3/docs/videos/insert) if it can help you. This function helps you to upload a video to YouTube and optionally sets the video's metadata. This video:insert has an optional parameter [`onBehalfOfContentOwnerChannel`](https://developers.google.com/youtube/v3/docs/videos/insert#onBehalfOfContentOwnerChannel) that helps you to specify the YouTube channel ID of the channel in which you add or upload the video. Check this [example code](https://developers.google.com/youtube/v3/docs/videos/insert#examples) on how to use it. – KENdi Dec 14 '16 at 09:44
  • @KENdi , I tried what you proposed, but I have some problems with it. Check out the edits on the post if you feel like. – chopeds Dec 19 '16 at 15:43
  • Check these SO question [32753205](http://stackoverflow.com/questions/32753205/youtube-video-insert-onbehalfofcontentowner-parameter-value) and [17209606](http://stackoverflow.com/questions/17209606/obtaining-the-current-users-youtube-content-owner-id) to know more about onBehalfOfContentOwner – KENdi Dec 20 '16 at 01:14

0 Answers0