سؤال

I have a website on which clients will be uploading videos. The thing is - I want those videos to be uploaded to OUR channel, not users' channels. I don't see how I could make it work using YouTube API v3.

Every time a person wants to upload something using the access token I provided he has to input his own credentials. He can't simply upload anything directly to OUR channel.

Is there a way to work that around?

هل كانت مفيدة؟

المحلول

Short answer is: You should not ask your users to upload into your account.

But please read further:

https://stackoverflow.com/a/12626209/1973552

https://stackoverflow.com/a/15258781/1973552

نصائح أخرى

Api V2 have option you've mentioned. Did you try it? Basically you want to let Users upload Videos in your website, but upload them directly to youtube, without Google AUTH?

Yes you can. Make sure you set the setAccessType to offline.

$client->setAccessType("offline");

This will make it so you get a refresh Token with the users account authentication the first time. A refresh token allows you to reauthenticate without the user being present. (aka, offline). Create your script from the sample API v3 scripts, authorize your main account (the one you want to be predetermined) and display the response. Something like the following will show you your response:

print_r($client->getAccessToken()); 

You will see your refresh Token in the json response. Save that (either to a database, or hard code it into the script). Now that you have a refresh token, whenever you want to upload to youtube, just call

$client->refreshToken($THE_REFRESH_TOKEN_YOU_SAVED);
$thetoken = $client->getAccessToken();
$client->setAccessToken($thetoken);

After this, your previously authenticated account will now be currently logged into your script.

FYI, these are php examples, you might need to adjust accordingly.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top