Forum Discussion
There is no get_auth_token_value() function in lithium_sso.php which i was provided by lithium
Am i missing any file?
Attached is the newest lithium_sso.php library we are using (with the get_auth_token_value() function).
- ismail14 years agoAdept
I have downloaded new lithiium_sso.php. Now php script not throwing error for function not found .
But REST API still returning authentication failed. here is the out put
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>- BradC14 years agoKhoros Alumni (Retired)
Can you please rerun the script to generate the token, and then send me a private message with the token? I will decrypt it and see if we can find out what's causing the user authentication error.
- RyanS13 years agoGuide
Thanks for the information in this thread it got me all the info I needed to get this working in my PHP script.
I used the base snippet from the OP, but customized it to work with my needs.
I have incorporated SimpleXMLElement to handle the outputted XML response.
As you can see, I have stored the Status of the response in a local variable as well as the returned session key value.
Both of which, I intend to use in logical checks in my script's error checking and subsequent REST API calls, respectively.
----------------------------------------------------------------
<?php // Sets the external IP of the Server making the REST API calls $external_ip_address = '<your_external_ip(i.e.., xxx.xxx.xxx.xxx)>'; // Secret SSO key (128-bit or 256-bit) provided by Lithium $sso_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; // Initialize Lithium SSO Client require_once("lithium_sso.php"); $lithium = new lithium_sso("<your company>", "<.your_company.com>", $sso_key); // (Optional) Additional user profile settings to pass to Lithium $settings_array = array(); $settings_array["roles.grant"] = "Administrator"; // Create the authentication token $liToken = $lithium->get_auth_token_value("<your_unique_id>", "<your_admin_username>", "<your_admin_email_address>", $settings_array, $lithium->get_server_var("HTTP_USER_AGENT"), $lithium->get_server_var("HTTP_REFERER"), $external_ip_address); $post_data="sso.authentication_token=$liToken"; $process = curl_init(); curl_setopt($process, CURLOPT_URL, 'http://<your_community>/<your_company>/restapi/vc/authentication/sessions/login'); curl_setopt($process, CURLOPT_TIMEOUT, 30); curl_setopt($process, CURLOPT_POST, 1); curl_setopt($process, CURLOPT_POSTFIELDS, $post_data); curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
$return = curl_exec($process);
curl_close($process);
$response = new SimpleXMLElement($return); echo 'response = ' . $response['status']; echo '<br>key = ' . $response->value; ?>
Related Content
- 4 years ago
- 2 years ago
- 13 years ago