FAQ  •  Register  •  Login

CDS Login prolbem

<<

GhostMaster75

Serviio newbie

Posts: 1

Joined: Mon May 04, 2015 1:50 pm

Post Mon May 04, 2015 2:02 pm

CDS Login prolbem

Hi,
I'm trying to use the API with PHP but are still at login.
He keeps telling me that my password is incorrect but does not with response 552.

this is my code:
  Code:
$data = date("D, d M Y H:i:s e");
$pass = "mypass";
$string = hash_hmac("sha1", $data, $pass);
$password = base64_encode($string);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost:23424/cds/login");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/xml | application/json", "Date: " . $data, "X-Serviio-Date: " . $data,  "Authorization: Serviio " . $password));
$response = curl_exec($ch);
curl_close($ch);

var_dump($response);


what's wrong???

thank you
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17216

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Tue May 05, 2015 4:35 pm

Re: CDS Login prolbem

the Accept header must be either application/xml or application/json
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17216

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Wed Mar 29, 2017 6:56 pm

Re: CDS Login prolbem

does this code produce the example value specified in the API docs?
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17216

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Thu Mar 30, 2017 8:04 am

Re: CDS Login prolbem

it looks ok to me. Do you get the right value when you use the date and password defined in the API ocs as an example? (search for "The following table shows a string, a fake Secret Access Key, and what the resulting base64 encoded signature would be.")
<<

y3ti

Serviio newbie

Posts: 7

Joined: Fri Jul 06, 2018 10:57 am

Post Mon Apr 08, 2019 11:51 am

Re: CDS Login prolbem

This is the code i use to Generate the Auth Token to then be able to pass through the API for the rest of the functions.

replace $server with your Server IP (eg: 192.168.x.x)
replace $pass with the password from your Serviio

  Code:
   $data = gmdate('D, d M Y H:i:s T');
   $auth_signature = base64_encode(hash_hmac("sha1", $data, $pass, true));
   
   $ch = curl_init();
   curl_setopt($ch,CURLOPT_VERBOSE, true);
   curl_setopt($ch,CURLOPT_HEADER, false);
   curl_setopt($ch,CURLOPT_URL, "http://" . $server . "/cds/login");
   curl_setopt($ch,CURLOPT_HTTPHEADER, array(
      "Content-Type: application/json",
      "Accept: application/json",
      "Date: " . $data,
      "X-Serviio-Date: " . $data,
      "Authorization: Serviio " . $auth_signature
   ));
   curl_setopt($ch,CURLOPT_POST, true);
   curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
   curl_setopt($ch,CURLOPT_FOLLOWLOCATION, true);
   curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);

   $output = curl_exec($ch);
   $info = curl_getinfo($ch);
   curl_close($ch);   

   $json = json_decode($output, true);
   
   @$authToken = $json['parameter'][0];


Hope this helps
Clifford

Main Serviio Server: Intel i5 4590T - 8GB Ram (Windows 10 Pro)
Node1: Intel i3 3220T - 8GB Ram - Dual network card (Windows 10 Pro)
Node2: Intel i3 3220T - 8GB Ram - Dual network card (Windows 10 Pro)
Node3: Intel i3 3220T - 8GB Ram - Dual network card (Windows 10 Pro)

Return to Third-party tools integration

Who is online

Users browsing this forum: No registered users and 37 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.