{"id":1639,"date":"2020-11-19T10:18:43","date_gmt":"2020-11-19T10:18:43","guid":{"rendered":"https:\/\/demo.securemetric.com\/docs\/?page_id=1639"},"modified":"2022-08-24T04:41:01","modified_gmt":"2022-08-24T12:41:01","slug":"sync-token-api-2","status":"publish","type":"page","link":"https:\/\/console.centagatecloud.com\/docs\/?page_id=1639","title":{"rendered":"Sync Token API"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"1639\" class=\"elementor elementor-1639\">\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-e045f9a elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"e045f9a\" 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-9278581\" data-id=\"9278581\" 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-072c40e elementor-widget elementor-widget-spacer\" data-id=\"072c40e\" 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-822b443 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"822b443\" 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-96f0b11\" data-id=\"96f0b11\" 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-76ba40c elementor-widget elementor-widget-heading\" data-id=\"76ba40c\" 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\">Sync Token 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-c08cf19 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"c08cf19\" 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-33264b1\" data-id=\"33264b1\" 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-cef1ce7 elementor-widget elementor-widget-text-editor\" data-id=\"cef1ce7\" 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 synchronize OTP token.<\/p>\n<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-775c818 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"775c818\" 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-d0e03d3\" data-id=\"d0e03d3\" 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-0c80d95 elementor-widget elementor-widget-code-block-for-elementor\" data-id=\"0c80d95\" 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-okaidia' data-show-toolbar='yes'><code class='language-http'>PUT \/CentagateWS\/webresources\/token\/syncToken\/{admin_username}<\/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-6f7e7b6 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"6f7e7b6\" 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-11e28c0\" data-id=\"11e28c0\" 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-3987f08 elementor-widget elementor-widget-heading\" data-id=\"3987f08\" 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-ca86022 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"ca86022\" 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-b303d4e\" data-id=\"b303d4e\" 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-77993e1 elementor-widget elementor-widget-htmega-datatable-addons\" data-id=\"77993e1\" data-element_type=\"widget\" data-widget_type=\"htmega-datatable-addons.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t        <div class=\"htmega-table-style htmega-table-style-2 htb-table-responsive\">\r\n            <table class=\"htb-table \">\r\n                                    <thead>\r\n                        <tr>\r\n                            <th class='elementor-repeater-item-eef8fe5'>No<\/th><th class='elementor-repeater-item-0e83012'>Name<\/th><th class='elementor-repeater-item-73ecc52'>Designation<\/th><th class='elementor-repeater-item-c4520d7'>Email<\/th>                        <\/tr>\r\n                    <\/thead>\r\n                                <tbody>\r\n                                            <tr>\r\n                            <td class=\"elementor-repeater-item-8e1be89\" >1<\/td><td class=\"elementor-repeater-item-883e8c0\" >Username<\/td><td class=\"elementor-repeater-item-2729b84\" >Required<\/td><td class=\"elementor-repeater-item-d1e89af\" >The User\u2019s Username<\/td>                        <\/tr>\r\n                                            <tr>\r\n                            <td class=\"elementor-repeater-item-909135c\" >2<\/td><td class=\"elementor-repeater-item-c8cdf8f\" >OtpStr1<\/td><td class=\"elementor-repeater-item-426d644\" >Required<\/td><td class=\"elementor-repeater-item-f076c58\" >The First OTP<\/td>                        <\/tr>\r\n                                            <tr>\r\n                            <td class=\"elementor-repeater-item-cd6ac3d\" >3<\/td><td class=\"elementor-repeater-item-9afeebc\" >OtpStr2<\/td><td class=\"elementor-repeater-item-3f3a396\" >Required<\/td><td class=\"elementor-repeater-item-441c7fe\" >The Second OTP<\/td>                        <\/tr>\r\n                                            <tr>\r\n                            <td class=\"elementor-repeater-item-0cf4156\" >4<\/td><td class=\"elementor-repeater-item-03c166f\" >CenToken<\/td><td class=\"elementor-repeater-item-9fa3120\" >Required<\/td><td class=\"elementor-repeater-item-99efb32\" >The Hmac Value Calculated Using SHA256 With SecretCode As Key And Plain Text From Admin Username + AuthToken<\/td>                        <\/tr>\r\n                                    <\/tbody>\r\n            <\/table>\r\n        <\/div>\r\n        \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-76663dc elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"76663dc\" 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-5d1eaaa\" data-id=\"5d1eaaa\" 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-1140727 elementor-widget elementor-widget-spacer\" data-id=\"1140727\" 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-5bb0951 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"5bb0951\" 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-d8d5e28\" data-id=\"d8d5e28\" 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-8103fa0 elementor-widget elementor-widget-heading\" data-id=\"8103fa0\" 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-d16c901 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"d16c901\" 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-27896b6\" data-id=\"27896b6\" 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-fdc61fb elementor-widget elementor-widget-text-editor\" data-id=\"fdc61fb\" 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-7a90f7f elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"7a90f7f\" 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-21ef4ec\" data-id=\"21ef4ec\" 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-20a1e0f elementor-tabs-view-horizontal elementor-widget elementor-widget-tabs\" data-id=\"20a1e0f\" 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-3421\" class=\"elementor-tab-title elementor-tab-desktop-title\" aria-selected=\"true\" data-tab=\"1\" role=\"tab\" tabindex=\"0\" aria-controls=\"elementor-tab-content-3421\" aria-expanded=\"false\"><a href=\"\">Java<\/a><\/div>\n\t\t\t\t\t\t\t\t\t<div id=\"elementor-tab-title-3422\" class=\"elementor-tab-title elementor-tab-desktop-title\" aria-selected=\"false\" data-tab=\"2\" role=\"tab\" tabindex=\"-1\" aria-controls=\"elementor-tab-content-3422\" aria-expanded=\"false\"><a href=\"\">Node Js<\/a><\/div>\n\t\t\t\t\t\t\t\t\t<div id=\"elementor-tab-title-3423\" class=\"elementor-tab-title elementor-tab-desktop-title\" aria-selected=\"false\" data-tab=\"3\" role=\"tab\" tabindex=\"-1\" aria-controls=\"elementor-tab-content-3423\" aria-expanded=\"false\"><a href=\"\">PHP<\/a><\/div>\n\t\t\t\t\t\t\t\t\t<div id=\"elementor-tab-title-3424\" class=\"elementor-tab-title elementor-tab-desktop-title\" aria-selected=\"false\" data-tab=\"4\" role=\"tab\" tabindex=\"-1\" aria-controls=\"elementor-tab-content-3424\" 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-3421\" aria-expanded=\"false\">Java<\/div>\n\t\t\t\t\t<div id=\"elementor-tab-content-3421\" class=\"elementor-tab-content elementor-clearfix\" data-tab=\"1\" role=\"tabpanel\" aria-labelledby=\"elementor-tab-title-3421\" tabindex=\"0\" hidden=\"false\"><p>\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"3195\" class=\"elementor elementor-3195\">\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-58c34f0 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"58c34f0\" 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-a9b33fa\" data-id=\"a9b33fa\" 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-1719b3c elementor-widget elementor-widget-code-block-for-elementor\" data-id=\"1719b3c\" 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\r\n\tGson gson = new Gson();\r\n\t\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\tHashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();\r\n\tmap.put(&quot;username&quot;, &quot;username&quot;);\r\n\tmap.put(&quot;otpStr1&quot;, &quot;otpStr1&quot;);\r\n\tmap.put(&quot;otpStr2&quot;, &quot;otpStr2&quot;);\r\n\tmap.put(&quot;cenToken&quot;, cenToken);  \r\n\r\n\tClientResponse response = service.path(&quot;token&quot;).path(&quot;syncToken&quot;).path(adminUsername).accept(MediaType.APPLICATION_JSON).put(ClientResponse.class, gson.toJson(map));\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-3422\" aria-expanded=\"false\">Node Js<\/div>\n\t\t\t\t\t<div id=\"elementor-tab-content-3422\" class=\"elementor-tab-content elementor-clearfix\" data-tab=\"2\" role=\"tabpanel\" aria-labelledby=\"elementor-tab-title-3422\" tabindex=\"0\" hidden=\"hidden\"><p>\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"3197\" class=\"elementor elementor-3197\">\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-f039859 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"f039859\" 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-87ea4bc\" data-id=\"87ea4bc\" 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-5246b84 elementor-widget elementor-widget-code-block-for-elementor\" data-id=\"5246b84\" 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\nvar username = &quot;&lt;username&gt;&quot;;\r\nvar otpStr1 = &quot;&lt;otpStr1&gt;&quot;;\r\nvar otpStr2 = &quot;&lt;otpStr2&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 data = JSON.stringify({\r\n\tusername: username,\r\n\totpStr1: otpStr1,\r\n\totpStr2: otpStr2,\r\n\tcenToken: hash\r\n})\r\n\r\nconst options = {\r\n\thostname: &quot;&lt;domain_name&gt;&quot;,\r\n\tport: 443,\r\n\tpath:'\/CentagateWS\/webresources\/token\/syncToken\/'+adminUsername,\r\n\tmethod: 'PUT',\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('data', 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-3423\" aria-expanded=\"false\">PHP<\/div>\n\t\t\t\t\t<div id=\"elementor-tab-content-3423\" class=\"elementor-tab-content elementor-clearfix\" data-tab=\"3\" role=\"tabpanel\" aria-labelledby=\"elementor-tab-title-3423\" tabindex=\"0\" hidden=\"hidden\"><p>\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"3199\" class=\"elementor elementor-3199\">\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-2b7b4a9 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"2b7b4a9\" 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-7db00fe\" data-id=\"7db00fe\" 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-5f3c321 elementor-widget elementor-widget-code-block-for-elementor\" data-id=\"5f3c321\" 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    $adminUsername = &quot;&lt;adminUsername&gt;&quot;;\r\n    $url = 'https:\/\/&lt;domain_name&gt;\/CentagateWS\/webresources\/token\/syncToken\/'.$adminUsername;\r\n    \r\n    $ch = curl_init($url);\r\n    \r\n    $username = &quot;&lt;username&gt;&quot;;\r\n    $otpStr1 = &quot;&lt;otpStr1&gt;&quot;;\r\n    $otpStr2 = &quot;&lt;otpStr2&gt;&quot;;\r\n    \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    $jsonData = array (\r\n    \t'username'=&gt; $username,\r\n    \t'otpStr1'=&gt; $otpStr1,\r\n    \t'otpStr2'=&gt; $otpStr2,\r\n    \t'cenToken' =&gt; $cenToken\r\n    );\r\n    \r\n    $jsonDataEncoded = json_encode($jsonData);\r\n    \r\n    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');\r\n    curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);\r\n    curl_setopt($ch, CURLOPT_HTTPHEADER, array('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-3424\" aria-expanded=\"false\">Error Code<\/div>\n\t\t\t\t\t<div id=\"elementor-tab-content-3424\" class=\"elementor-tab-content elementor-clearfix\" data-tab=\"4\" role=\"tabpanel\" aria-labelledby=\"elementor-tab-title-3424\" tabindex=\"0\" hidden=\"hidden\"><p>\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"4084\" class=\"elementor elementor-4084\">\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-19efd78 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"19efd78\" 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-ea3d458\" data-id=\"ea3d458\" 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-6252d72 elementor-widget elementor-widget-Table\" data-id=\"6252d72\" 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><\/tr><tr><td   class=\"elementor-repeater-item-b5f2d78\" >22002<\/td><td   class=\"elementor-repeater-item-86d1d3a\" >User not found<\/td><\/tr><tr><td   class=\"elementor-repeater-item-2caf6a3\" >29001<\/td><td   class=\"elementor-repeater-item-a4ccdc1\" >Token not found<\/td><\/tr><tr><td   class=\"elementor-repeater-item-8d0fa00\" >29002<\/td><td   class=\"elementor-repeater-item-ad5bcb0\" >Token is not active<\/td><\/tr><tr><td   class=\"elementor-repeater-item-1293d73\" >29003<\/td><td   class=\"elementor-repeater-item-c313636\" >Token is not bound to the user<\/td><\/tr><tr><td   class=\"elementor-repeater-item-ba1c42d\" >29013<\/td><td   class=\"elementor-repeater-item-5a61d64\" >Token is not bound to anyone<\/td><\/tr><tr><td   class=\"elementor-repeater-item-7c44653\" >54002<\/td><td   class=\"elementor-repeater-item-4eb9fad\" >Sync OTP failed<\/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>Sync Token API Call this function to synchronize OTP token. Below is the URL to access the API functions: PUT \/CentagateWS\/webresources\/token\/syncToken\/{admin_username} Parameters No Name Designation Email 1 Username Required The User\u2019s Username 2 OtpStr1 Required The First OTP 3 OtpStr2 Required The Second OTP 4 CenToken Required The Hmac Value Calculated Using SHA256 With SecretCode [&hellip;]<\/p>\n<a class=\"read-more-tag\" \n         href=\"https:\/\/console.centagatecloud.com\/docs\/?page_id=1639\">&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\/1639"}],"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=1639"}],"version-history":[{"count":28,"href":"https:\/\/console.centagatecloud.com\/docs\/index.php?rest_route=\/wp\/v2\/pages\/1639\/revisions"}],"predecessor-version":[{"id":6222,"href":"https:\/\/console.centagatecloud.com\/docs\/index.php?rest_route=\/wp\/v2\/pages\/1639\/revisions\/6222"}],"wp:attachment":[{"href":"https:\/\/console.centagatecloud.com\/docs\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}