{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Single Sign-On","description":"Developer documentation for the WHMCS API — the","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"single-sign-on","__idx":0},"children":["Single Sign-On"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Single sign-on can occur for a service or server."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Whichever method being used, the return should be the same."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The return from either function should always be an array and contain two keys of a possible three."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["success - This is a ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://docs.whmcs.com/Glossary#Boolean"},"children":["boolean"]}," value and should indicate success or failure"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["redirectTo - This should be a fully formatted URL return from your SSO request"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["errorMsg - Any appropriate error message to be displayed to whoever is making the request"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"service-single-sign-on","__idx":1},"children":["Service Single Sign-On ",{"$$mdtype":"Tag","name":"a","attributes":{"id":"service-sso"},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Service single sign-on is to allow admin and client users to login to the control panel of the service automatically."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"/**\n * Perform single sign-on for a given instance of a product/service.\n *\n * Called when single sign-on is requested for an instance of a product/service.\n *\n * When successful, returns an URL to which the user should be redirected.\n *\n * @param array $params common module parameters\n *\n * @see https://developers.whmcs.com/provisioning-modules/module-parameters/\n *\n * @return array\n */\nfunction mymodule_ServiceSingleSignOn(array $params)\n{\n\t$return = array(\n\t\t'success' => false,\n\t);\n\ttry {\n        /**\n         * all the service's single sign-on token retrieval function, using the\n         * values provided by WHMCS in `$params`.\n         * The variables and response format would depend on your server API\n         */\n\n        $response = $formattedResponse = custom_call_to_server();\n\n        $return = array(\n            'success' => true,\n            'redirectTo' => $response['redirectUrl'],\n        );\n    } catch (Exception $e) {\n        $return['errorMsg'] = $e->getMessage();\n        $response = $e->getMessage();\n        $formattedResponse = $e->getTraceAsString();\n    }\n\n    /**\n     * Log any call to the server\n     */\n\tlogModuleCall(\n        'provisioningmodule',\n        __FUNCTION__,\n        $params,\n        $response,\n        $formattedResponse,\n        array('username', 'password')\n    );\n\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In order to call your ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["_ServiceSingleSignOn"]}," function from the Client Area, create a button or link that uses the following URL format:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"/clientarea.php?action=productdetails&id=SERVICE_ID_HERE&dosinglesignon=1\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Replace ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["SERVICE_ID_HERE"]}," with the ID of the client's service that you wish to perform the single sign-on with."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The most common methods of displaying the link are; in the sidebar, or a button in the client area output of the module. The following resources go into further detail on how to use the WHMCS hooks system or client area output in a module:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["https://developers.whmcs.com/themes/sidebars/"," ","https://developers.whmcs.com/provisioning-modules/client-area-output/"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"server-single-sign-on","__idx":2},"children":["Server Single Sign-On ",{"$$mdtype":"Tag","name":"a","attributes":{"id":"server-sso"},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Server single sign-on allows for Admin users to login to the associated server management panel (like WHM for cPanel) automatically."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"/**\n * Perform single sign-on for a server.\n *\n * Called when single sign-on is requested for a server assigned to the module.\n *\n * This differs from ServiceSingleSignOn in that it relates to a server\n * instance within the admin area, as opposed to a single client instance of a\n * product/service.\n *\n * When successful, returns an URL to which the user should be redirected to.\n *\n * @param array $params common module parameters\n *\n * @see https://developers.whmcs.com/provisioning-modules/module-parameters/\n *\n * @return array\n */\nfunction mymodule_AdminSingleSignOn(array $params)\n{\n\t$return = array(\n\t\t'success' => false,\n\t);\n\ttry {\n        /**\n         * all the service's single sign-on token retrieval function, using the\n         * values provided by WHMCS in `$params`.\n         * The variables and response format would depend on your server API\n         */\n\n        $response = $formattedResponse = custom_call_to_server();\n\n        $return = array(\n            'success' => true,\n            'redirectTo' => $response['redirectUrl'],\n        );\n    } catch (Exception $e) {\n        $return['errorMsg'] = $e->getMessage();\n        $response = $e->getMessage();\n        $formattedResponse = $e->getTraceAsString();\n    }\n\n    /**\n     * Log any call to the server\n     */\n\tlogModuleCall(\n        'provisioningmodule',\n        __FUNCTION__,\n        $params,\n        $response,\n        $formattedResponse,\n        array('username', 'password')\n    );\n\n}\n"},"children":[]}]},"headings":[{"value":"Single Sign-On","id":"single-sign-on","depth":1},{"value":"Service Single Sign-On","id":"service-single-sign-on","depth":2},{"value":"Server Single Sign-On","id":"server-single-sign-on","depth":2}],"frontmatter":{"title":"Single Sign-On","seo":{"title":"Single Sign-On"}},"lastModified":"2026-08-03T17:00:42.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/provisioning-modules/single-sign-on","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}