Hi,
I’m trying to change ownership of a video via API.
I call the API via PHP curl from my PC.
I can list the videos and get the UUIDs but when I call the give-ownership, the server replies with « Changing video ownership to a remote account is not supported yet ». What do you mean by « remote account »?
Hi!
Remote accounts are accounts from another PeerTube server.
I guess you tried to give ownership to an user from a different server from the original owner of the video.
As stated, this feature is not supported yet.
Unfortunately not, the two accounts are on the same server. And are also « local » (not OIDC)
Okay, my technical knowledge is not important enough to help you then.
Let’s wait until @Chocobozzz have some time to answer you!
Hi,
Could you paste your instance URL and the account you want to give the video to?
Hi,
Sure.
Instance https://video.cnr.it
Source User: formazione
Dest. User: giorgio.test
Both are local user created on the instance (local authentication)
Thanks, and could you paste your PHP code?
This the code I’m using in PHP:
<?php
$url='https://video.cnr.it';
$user='formazione';
$giveTo='giorgio.test';
//GET CLIENT ID & SECRET
.....
//USE CLIENT ID & SECRET TO GET TOKEN
.....
$token=json_decode(curl_exec($curl),TRUE);
//GET VIDEO LIST USING TOKEN
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url.'/api/v1/accounts/'.$user.'/videos?count=100',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer '.$token['access_token']),
));
$response = curl_exec($curl);
curl_close($curl);
//PRINT VIDEO LIST
$videos=json_decode($response,TRUE);
echo $videos['total'].PHP_EOL;
foreach ($videos['data'] as $video){
echo $video['name'].' - '.$video['uuid'].' - '.$video['id'].PHP_EOL;
}
// ASK TO CHANGE OWNERSHIP
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url.'/api/v1/videos/SOME-UUID/give-ownership',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => 'username="'.$giveTo.'"',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Bearer '.$token['access_token']),
));
$response = curl_exec($curl);
var_dump(json_decode($response,TRUE));
curl_close($curl);
//HERE CAMES THE ERROR
array(5) {
["type"]=>
string(11) "about:blank"
["title"]=>
string(11) "Bad Request"
["detail"]=>
string(65) "Changing video ownership to a remote account is not supported yet"
["status"]=>
int(400)
["error"]=>
string(65) "Changing video ownership to a remote account is not supported yet"