Page 1 of 1
Authentication API
Posted: Tue May 07, 2024 4:47 pm
by kthroc23
Can anyone help with the Authentication API with the new version 4.0.7?
I have a simple php website that I want to authenticate users by the API of Forma. I have followed the documentation and still does not work.
Re: Authentication API
Posted: Tue May 07, 2024 5:04 pm
by alfa24
Hi, you should provide more details. Code used to achieve the auth, what errors do you get, and so on.
Re: Authentication API
Posted: Tue May 07, 2024 6:01 pm
by kthroc23
This is my simple code below. Is my API call correct? Also, this code worked for FORMA 2.3.0. I am not sure if anything changed.
Code: Select all
$params = array("username"=>'[email protected]', "password"=>'password');
$key = "testtesttest";
$secret = "password";
$codice_sha1 = strtolower(sha1(implode(',', $params) . ',' . $secret));
$codice = base64_encode($key . ":" . $codice_sha1);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://lms.mylms.com/api/auth/authenticate",
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $params,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Authorization: FormaLMS " . $codice,
],
));
$response = curl_exec($curl);
$error = curl_error($curl);
curl_close($curl);
$xml = simplexml_load_string($response);
$json = json_encode($xml);
$array = json_decode($json,TRUE);
echo json_encode($array);
Re: Authentication API
Posted: Wed May 08, 2024 7:17 am
by alfa24
What do you obtain?
I mean, $response and/or $error ?
Re: Authentication API
Posted: Wed May 08, 2024 3:58 pm
by kthroc23
The response data is the 404 server error saying that File or directory not found.
Re: Authentication API
Posted: Wed May 08, 2024 4:02 pm
by alfa24
It's the URL to be call correct? I suppose it's not
https://lms.mylms.com/api/auth/authenticate...
If you're not able to debug such an easy problem, I'd suggest to hire a developer or you'll risk more serious issues.
Re: Authentication API
Posted: Thu May 09, 2024 9:41 pm
by kthroc23
Can you or anyone show me a simple url for the API call?
For Forma version 4.0.7, Which of the follow should be the API url to check for username?
a) lms.forma.com/api/user/checkUsername
b) lms.forma.com/api/rest.php?q=/api/user/checkUsername
or
c) please provide an example URL call to the the rest api.
Re: Authentication API
Posted: Fri May 10, 2024 7:38 am
by alfa24