Self Help Documentation
Single sign-on (SSO)
Description
Generates a single sign-on (SSO) token which can be used for secure login in SPanel without entering a password.
Warning
The authorizing API token which is going to be used must have the SSO option switched on.
Parameters
Field | Type | Required | Description |
---|---|---|---|
token | string | Yes | Authorizing API token – check API Basics for more information. |
username | string | Yes | Valid SPanel user, subuser or admin username. |
role | string | Yes | Role of the provided user. Possible values: “user” or “admin”. |
action | string | Yes | The SPanel API function which generates the SSO link. It’s always “base/sso”. |
ip | string | No | Additional layer of security – provide a valid IPv4 address from which the login will be performed via the generated link. |
redirect | string | No | Valid existent SPanel page in format “category/page”. Defaults to the index page, if nothing provided. |
Info
Generated SSO tokens have a very short lifespan. They must be used immediately after creation.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
$endpointUrl = 'https://123.123.123.123/spanel/api.php'; $postData = [ 'token' => 'provided_auth_token', 'role' => 'admin', 'action' => 'base/sso', //'ip' => '123.123.123.123', //'redirect' => 'server/information', ]; $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $endpointUrl); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt( $ch, CURLOPT_POST, true); curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query($postData)); curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false); $jsonOutput = curl_exec( $ch ); |
You can find more information about the Endpoint URL in our API Basics article.
Output
1 2 3 4 5 6 7 |
{ "result": "success", "data": { "token": "50b27fd1951396ae0bd71595ac0f19566b0d0180", "url": "https://spanel.io/spanel/sso/50b27fd1951396ae0bd71595ac0f19566b0d0180" } } |