{"id":1692,"date":"2020-11-19T14:10:38","date_gmt":"2020-11-19T14:10:38","guid":{"rendered":"https:\/\/demo.securemetric.com\/docs\/?page_id=1692"},"modified":"2022-08-24T04:27:25","modified_gmt":"2022-08-24T12:27:25","slug":"check-user-session","status":"publish","type":"page","link":"https:\/\/console.centagatecloud.com\/docs\/?page_id=1692","title":{"rendered":"Check User Session API"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"1692\" class=\"elementor elementor-1692\">\n\t\t\t\t\t\t<div class=\"elementor-inner\">\n\t\t\t\t<div class=\"elementor-section-wrap\">\n\t\t\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-4738321 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"4738321\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-cf0f90a\" data-id=\"cf0f90a\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-720087f elementor-widget elementor-widget-spacer\" data-id=\"720087f\" data-element_type=\"widget\" data-widget_type=\"spacer.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-spacer\">\n\t\t\t<div class=\"elementor-spacer-inner\"><\/div>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-e001269 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"e001269\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-5e6d8cc\" data-id=\"5e6d8cc\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-f0e4189 elementor-widget elementor-widget-heading\" data-id=\"f0e4189\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Check User Session API<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-af8fc2d elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"af8fc2d\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-1e22270\" data-id=\"1e22270\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-dc74ead elementor-widget elementor-widget-text-editor\" data-id=\"dc74ead\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\">\n\t\t\t\t<p>Call this function to check user session is active or inactive.<\/p><p>Below is the URL to access the API functions:<\/p>\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-1e2bcbc elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"1e2bcbc\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-b60e7f2\" data-id=\"b60e7f2\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-bae9822 elementor-widget elementor-widget-code-block-for-elementor\" data-id=\"bae9822\" data-element_type=\"widget\" data-widget_type=\"code-block-for-elementor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<pre class='theme-twilight' data-show-toolbar='yes'><code class='language-http'>PUT \/CentagateWS\/webresources\/session\/check\/{username}\/{cenToken}<\/code><\/pre>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-2859553 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"2859553\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-6cf7ce4\" data-id=\"6cf7ce4\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-931389a elementor-widget elementor-widget-heading\" data-id=\"931389a\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Parameters<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-aa58fa7 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"aa58fa7\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-2a4e17f\" data-id=\"2a4e17f\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-53eab3a elementor-widget elementor-widget-text-editor\" data-id=\"53eab3a\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\">\n\t\t\t\t<p>For the parameters no need.<\/p>\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-02984d2 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"02984d2\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-06eaa3e\" data-id=\"06eaa3e\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-78cc44f elementor-widget elementor-widget-heading\" data-id=\"78cc44f\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-xl\">Sample Code<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-6a822f9 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"6a822f9\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-24fcc12\" data-id=\"24fcc12\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-314c7ef elementor-widget elementor-widget-text-editor\" data-id=\"314c7ef\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-text-editor elementor-clearfix\">\n\t\t\t\t<p>As in below there are some examples of source code of access the API functions:<\/p>\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-06d5e30 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"06d5e30\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-725ea03\" data-id=\"725ea03\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-eebc753 elementor-tabs-view-horizontal elementor-widget elementor-widget-tabs\" data-id=\"eebc753\" data-element_type=\"widget\" data-widget_type=\"tabs.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-tabs\">\n\t\t\t<div class=\"elementor-tabs-wrapper\" role=\"tablist\" >\n\t\t\t\t\t\t\t\t\t<div id=\"elementor-tab-title-2501\" class=\"elementor-tab-title elementor-tab-desktop-title\" aria-selected=\"true\" data-tab=\"1\" role=\"tab\" tabindex=\"0\" aria-controls=\"elementor-tab-content-2501\" aria-expanded=\"false\"><a href=\"\">Java<\/a><\/div>\n\t\t\t\t\t\t\t\t\t<div id=\"elementor-tab-title-2502\" class=\"elementor-tab-title elementor-tab-desktop-title\" aria-selected=\"false\" data-tab=\"2\" role=\"tab\" tabindex=\"-1\" aria-controls=\"elementor-tab-content-2502\" aria-expanded=\"false\"><a href=\"\">Node Js<\/a><\/div>\n\t\t\t\t\t\t\t\t\t<div id=\"elementor-tab-title-2503\" class=\"elementor-tab-title elementor-tab-desktop-title\" aria-selected=\"false\" data-tab=\"3\" role=\"tab\" tabindex=\"-1\" aria-controls=\"elementor-tab-content-2503\" aria-expanded=\"false\"><a href=\"\">PHP<\/a><\/div>\n\t\t\t\t\t\t\t\t\t<div id=\"elementor-tab-title-2504\" class=\"elementor-tab-title elementor-tab-desktop-title\" aria-selected=\"false\" data-tab=\"4\" role=\"tab\" tabindex=\"-1\" aria-controls=\"elementor-tab-content-2504\" aria-expanded=\"false\"><a href=\"\">Error Code<\/a><\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t\t<div class=\"elementor-tabs-content-wrapper\" role=\"tablist\" aria-orientation=\"vertical\">\n\t\t\t\t\t\t\t\t\t<div class=\"elementor-tab-title elementor-tab-mobile-title\" aria-selected=\"true\" data-tab=\"1\" role=\"tab\" tabindex=\"0\" aria-controls=\"elementor-tab-content-2501\" aria-expanded=\"false\">Java<\/div>\n\t\t\t\t\t<div id=\"elementor-tab-content-2501\" class=\"elementor-tab-content elementor-clearfix\" data-tab=\"1\" role=\"tabpanel\" aria-labelledby=\"elementor-tab-title-2501\" tabindex=\"0\" hidden=\"false\"><p>\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"3286\" class=\"elementor elementor-3286\">\n\t\t\t\t\t\t<div class=\"elementor-inner\">\n\t\t\t\t<div class=\"elementor-section-wrap\">\n\t\t\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-cdcecce elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"cdcecce\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-78136e4\" data-id=\"78136e4\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-a227a02 elementor-widget elementor-widget-code-block-for-elementor\" data-id=\"a227a02\" data-element_type=\"widget\" data-widget_type=\"code-block-for-elementor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<pre class='line-numbers theme-tomorrow-night' data-show-toolbar='yes'><code class='language-java'>public static void main(String[] args) {\r\n\r\n\tClientConfig config = new DefaultClientConfig ();\r\n\tClient client = Client.create ( config );\r\n\tWebResource service = client.resource (&quot;https:\/\/&lt;domain_name&gt;\/CentagateWS\/webresources&quot;);\r\n\t\t\t\t\t\t\r\n\tGson gson = new Gson();\r\n\t\r\n\tString username = &quot;{username}&quot;;\r\n\tString authToken = &quot;{authToken}&quot;\r\n\tString adminUsername = &quot;{adminUsername}&quot;;\r\n\tString secretCode &quot;{secretCode}&quot;;\r\n\tString cenToken = convertHmacSha256(secretCode, adminUsername + authToken);\r\n\r\n\tClientResponse response = service.path(&quot;session&quot;).path(&quot;check&quot;).path(username).path(cenToken).accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);\r\n\t\t\t\t\r\n\tString retJson = response.getEntity(String.class);\r\n\r\n\tHashMap&lt;String, Object&gt; returnData = (HashMap&lt;String, Object&gt;) gson.fromJson(retJson, HashMap.class);\r\n\r\n\tString code = returnData.get(&quot;code&quot;).toString();\r\n\tString message = returnData.get(&quot;message&quot;).toString();\r\n\tString object = returnData.get(&quot;object&quot;).toString();\r\n}\r\n\r\npublic static String convertHmacSha256(String secretKey, String params) throws NoSuchAlgorithmException, \r\n            InvalidKeyException,IllegalStateException, SignatureException, NoSuchProviderException, Exception\r\n{\r\n\ttry\r\n\t{\r\n\t\tfinal SecretKeySpec secret_key = new SecretKeySpec ( StringUtils.getBytesUtf8 ( secretKey ) , &quot;HmacSHA256&quot; );\r\n\t\tfinal Mac mac = Mac.getInstance ( &quot;HmacSHA256&quot; );\r\n\t\tmac.init ( secret_key );\r\n\t\tfinal byte[] bytes = mac.doFinal ( StringUtils.getBytesUtf8 ( params ) );\r\n\t\treturn Hex.encodeHexString ( bytes );\r\n\t}\r\n\tcatch ( NoSuchAlgorithmException e )\r\n\t{\r\n\t\tthrow new NoSuchAlgorithmException ( e );\r\n\t}\r\n\tcatch ( InvalidKeyException e )\r\n\t{\r\n\t\tthrow new InvalidKeyException ( e );\r\n\t}\r\n\tcatch ( IllegalStateException e )\r\n\t{\r\n\t\tthrow new IllegalStateException ( e );\r\n\t}\r\n\tcatch ( Exception e )\r\n\t{\r\n\t\tthrow new Exception ( e );\r\n\t}\r\n}<\/code><\/pre>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/p><\/div>\n\t\t\t\t\t\t\t\t\t<div class=\"elementor-tab-title elementor-tab-mobile-title\" aria-selected=\"false\" data-tab=\"2\" role=\"tab\" tabindex=\"-1\" aria-controls=\"elementor-tab-content-2502\" aria-expanded=\"false\">Node Js<\/div>\n\t\t\t\t\t<div id=\"elementor-tab-content-2502\" class=\"elementor-tab-content elementor-clearfix\" data-tab=\"2\" role=\"tabpanel\" aria-labelledby=\"elementor-tab-title-2502\" tabindex=\"0\" hidden=\"hidden\"><p>\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"3288\" class=\"elementor elementor-3288\">\n\t\t\t\t\t\t<div class=\"elementor-inner\">\n\t\t\t\t<div class=\"elementor-section-wrap\">\n\t\t\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-28d37e8 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"28d37e8\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-2311974\" data-id=\"2311974\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-6087eed elementor-widget elementor-widget-code-block-for-elementor\" data-id=\"6087eed\" data-element_type=\"widget\" data-widget_type=\"code-block-for-elementor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<pre class='line-numbers theme-tomorrow-night' data-show-toolbar='yes'><code class='language-javascript'>const https = require('https')\r\n\r\nvar crypto = require('crypto');\r\n\r\nvar username = &quot;&lt;username&gt;&quot;;\r\n\r\nvar adminUsername = &quot;&lt;adminUsername&gt;&quot;;\r\nvar authToken = &quot;&lt;authToken&gt;&quot;;\r\nvar secretCode = &quot;&lt;secretCode&gt;&quot;;\r\n  \r\nvar cenTokenText = adminUsername + authToken;\r\nvar hash, cenToken;\r\n\r\n\/* generate cenToken value*\/\r\ncenToken = crypto.createHmac(sha256, secretCode);    \r\ncenToken.write(cenTokenText);\r\ncenToken.end();      \r\nhash = cenToken.read().toString('hex');    \r\n\r\nconst options = {\r\n\thostname: &quot;&lt;domain_name&gt;&quot;,\r\n\tport: 443,\r\n\tpath:'\/CentagateWS\/webresources\/session\/check\/'+username+'\/'+hash,\r\n\tmethod: 'GET',\r\n\theaders: {\r\n\t\t'Accept': 'application\/json',\r\n\t\t'Content-Type': 'application\/json',\r\n\t}\r\n}\r\n\r\nconst req = https.request(options, res =&gt;{\r\n\tconsole.log(`HTTP Status Code: ${res.statusCode}`)\r\n\tvar body = '';\r\n\tres.on('', function(d){\r\n\t\t\r\n\tbody += d;\r\n\tvar parsed = JSON.parse(body);\r\n\t\r\n\tif (parsed.code == 0){\r\n\t   console.log('Authentication Succeed');\r\n\t   console.log('Response:');\r\n\t   console.log(body);\r\n\t}\r\n\telse {\r\n\t  console.log('Authentication Fail, ' +'Message:' + parsed.message);\r\n\t  console.log('Code:' + parsed.code); \r\n\t}\r\n\t\t\r\n\t})\r\n})\r\n\r\nreq.on('ERROR', error =&gt; {\r\n\tconsole.error(error)\r\n})\r\n\r\nreq.write(data)\r\nreq.end()<\/code><\/pre>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/p><\/div>\n\t\t\t\t\t\t\t\t\t<div class=\"elementor-tab-title elementor-tab-mobile-title\" aria-selected=\"false\" data-tab=\"3\" role=\"tab\" tabindex=\"-1\" aria-controls=\"elementor-tab-content-2503\" aria-expanded=\"false\">PHP<\/div>\n\t\t\t\t\t<div id=\"elementor-tab-content-2503\" class=\"elementor-tab-content elementor-clearfix\" data-tab=\"3\" role=\"tabpanel\" aria-labelledby=\"elementor-tab-title-2503\" tabindex=\"0\" hidden=\"hidden\"><p>\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"3290\" class=\"elementor elementor-3290\">\n\t\t\t\t\t\t<div class=\"elementor-inner\">\n\t\t\t\t<div class=\"elementor-section-wrap\">\n\t\t\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-ddb9c3d elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"ddb9c3d\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-ed0e430\" data-id=\"ed0e430\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-9a83075 elementor-widget elementor-widget-code-block-for-elementor\" data-id=\"9a83075\" data-element_type=\"widget\" data-widget_type=\"code-block-for-elementor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<pre class='line-numbers theme-tomorrow-night' data-show-toolbar='yes'><code class='language-php'>&lt;?php\r\n\r\n    $username = &quot;&lt;username&gt;&quot;;\r\n    $secretCode = &quot;&lt;secretCode&gt;&quot;;\r\n    $authToken = &quot;&lt;authToken&gt;&quot;;\r\n    $cenToken_text = $adminUsername.$authToken;\r\n    $cenToken = hash_hmac('sha256', $cenToken_text, $secretCode); \/\/ calculate cenToken value\r\n    \r\n    $url = 'https:\/\/&lt;domain_name&gt;\/CentagateWS\/webresources\/session\/check\/'.$username.'\/'.$cenToken;\r\n    \r\n    $ch = curl_init($url);\r\n    \r\n    curl_setopt($ch, CURLOPT_CUSTOMREQUEST,&quot;GET&quot;);\r\n    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application\/json','Content-Type: application\/json'));\r\n    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\r\n    \r\n    $result = curl_exec($ch);\r\n    \r\n    \r\n    $obj = json_decode($result); \r\n    if ($obj-&gt;{'code'} != 0){\r\n    \tprint &quot;Authentication fail&quot;;\r\n    \tprint &quot;Message: &quot;.$obj-&gt;{'message'}; \r\n    \techo &quot; &lt;br&gt;&quot;; \r\n    \tprint &quot;Code: &quot;.$obj-&gt;{'code'};\r\n    }\r\n    else {\r\n    \tprint &quot;Authentication succeed&quot;;\r\n    \techo &quot; &lt;br&gt;&quot;; \r\n    \tprint &quot;Message: &quot;.$obj-&gt;{'message'}; \r\n    \techo &quot; &lt;br&gt;&quot;; \r\n    \tprint &quot;Code: &quot;.$obj-&gt;{'code'}; \r\n    \techo &quot; &lt;br&gt;&quot;; \r\n    \tprint &quot;Result:&quot; ;\r\n    \techo &quot; &lt;br&gt;&quot;; \r\n    \tprint $result;\r\n    }\r\n    \r\n    curl_close($ch);\r\n\r\n?&gt;<\/code><\/pre>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/p><\/div>\n\t\t\t\t\t\t\t\t\t<div class=\"elementor-tab-title elementor-tab-mobile-title\" aria-selected=\"false\" data-tab=\"4\" role=\"tab\" tabindex=\"-1\" aria-controls=\"elementor-tab-content-2504\" aria-expanded=\"false\">Error Code<\/div>\n\t\t\t\t\t<div id=\"elementor-tab-content-2504\" class=\"elementor-tab-content elementor-clearfix\" data-tab=\"4\" role=\"tabpanel\" aria-labelledby=\"elementor-tab-title-2504\" tabindex=\"0\" hidden=\"hidden\"><p>\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"4115\" class=\"elementor elementor-4115\">\n\t\t\t\t\t\t<div class=\"elementor-inner\">\n\t\t\t\t<div class=\"elementor-section-wrap\">\n\t\t\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-e53cbde elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"e53cbde\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t\t\t<div class=\"elementor-row\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-74a7701\" data-id=\"74a7701\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-column-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-b007844 elementor-widget elementor-widget-Table\" data-id=\"b007844\" data-element_type=\"widget\" data-widget_type=\"Table.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<table class=\"tafe-table\">\n\t\t\t<thead  class=\"tafe-table-header\">\n\t\t\t\t<tr>\n\t\t\t\t\t<th class=\"elementor-inline-editing elementor-repeater-item-709daa8\"   >Return Code<\/th><th class=\"elementor-inline-editing elementor-repeater-item-ff318f2\"   >Details<\/th>\t\t\t\t<\/tr>\n\t\t\t<\/thead>\n\t\t\t<tbody class=\"tafe-table-body\">\n\t\t\t\t<tr>\n\t\t\t\t\t<td   class=\"elementor-repeater-item-0b74d50\" >0<\/td><td   class=\"elementor-repeater-item-4a03917\" >Success<\/td><\/tr><tr><td   class=\"elementor-repeater-item-697448a\" >10001<\/td><td   class=\"elementor-repeater-item-4ceaa8f\" >Permission not allowed<\/td><\/tr><tr><td   class=\"elementor-repeater-item-5a39c17\" >10002<\/td><td   class=\"elementor-repeater-item-e6d3e52\" >Invalid Input<\/td><\/tr><tr><td   class=\"elementor-repeater-item-00d5337\" >10003<\/td><td   class=\"elementor-repeater-item-614d010\" >DB protection error<\/td><\/tr><tr><td   class=\"elementor-repeater-item-ed5c271\" >10004<\/td><td   class=\"elementor-repeater-item-878f6c1\" >DB error<\/td><\/tr><tr><td   class=\"elementor-repeater-item-91ba6bf\" >10011<\/td><td   class=\"elementor-repeater-item-e7fcefe\" >Crypto error<\/td>\t\t\t\t<\/tr>\n\t\t\t<\/tbody>\n\t\t<\/table>\n\t\t\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/p><\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Check User Session API Call this function to check user session is active or inactive. Below is the URL to access the API functions: PUT \/CentagateWS\/webresources\/session\/check\/{username}\/{cenToken} Parameters For the parameters no need. Sample Code As in below there are some examples of source code of access the API functions: Java Node Js PHP Error Code [&hellip;]<\/p>\n<a class=\"read-more-tag\" \n         href=\"https:\/\/console.centagatecloud.com\/docs\/?page_id=1692\">&nbsp;Read More<\/a>","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/console.centagatecloud.com\/docs\/index.php?rest_route=\/wp\/v2\/pages\/1692"}],"collection":[{"href":"https:\/\/console.centagatecloud.com\/docs\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/console.centagatecloud.com\/docs\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/console.centagatecloud.com\/docs\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/console.centagatecloud.com\/docs\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1692"}],"version-history":[{"count":37,"href":"https:\/\/console.centagatecloud.com\/docs\/index.php?rest_route=\/wp\/v2\/pages\/1692\/revisions"}],"predecessor-version":[{"id":6198,"href":"https:\/\/console.centagatecloud.com\/docs\/index.php?rest_route=\/wp\/v2\/pages\/1692\/revisions\/6198"}],"wp:attachment":[{"href":"https:\/\/console.centagatecloud.com\/docs\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}