Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allow users to upload videos to my channel using youtube API v3

Using Google API v3 php library . I want the user to upload videos on my youtube channel. But oAuth require user google login and the video uploaded to the logged in user youtube channel.

Before using the V3 api we used the V2 to upload the video and it works well.

global $youtube_api_key, $youtube_username, $youtube_password;

if(is_file('../uploader/ClassYouTubeAPI.php')){ include_once ('../uploader/ClassYouTubeAPI.php'); }
else{ include_once('ClassYouTubeAPI.php'); }

$obj = new ClassYouTubeAPI($youtube_api_key);
$result = $obj->clientLoginAuth($youtube_username, $youtube_password);
$result = $obj->uploadVideo($uploaded_file_name, $file_path, $title, $description, $privacy);
var_dump($result);
if (is_array($result) and count($result) and ! isset($result["is_error"])) {
    $youtube_file = str_replace($uploaded_file_name, $result["videoId"] . '.youtube', $file_path);
    $resource = fopen($youtube_file, 'w');
    fwrite($resource, "");


    fclose($resource);

    @unlink($file_path);

    return $result["videoId"];
} else {
    @unlink($file_path);
    return false;
}

Is there any way to use the V3 without 'User Google Account' and upload the video to my channel?

like image 433
user3923074 Avatar asked Nov 01 '22 16:11

user3923074


1 Answers

There is only one solution, described here.

In short, you must create a "web application" account (not a "service account") in Google console and do authentication from your server on behalf of your YouTube account.

like image 197
Cookie Monster Avatar answered Nov 09 '22 03:11

Cookie Monster