Articles in this section
Category / Section

How to fix the error "Embed Code Validation Failed"?

Published:

The error Embed code validation failed occurs while embedding Bold BI in your application due to the reasons listed below:

    1. When the embedded application uses an older Embed secret instead of the latest one.

    2. When there is a time difference between the embedded application-hosted machine and the Bold BI server-hosted machine.


Steps to be followed when an issue is due to an outdated Embed secret key:

  1. Go to the Settings page in the Bold BI server and select Embed option like in the below image.

              

      2.  In the Embed Settings page, you can find the Download button to download a JSON file that contains the latest Embed secret key.
              

      3. Replace the Embed secret key in your embedded application with Embed secret key available in the downloaded JSON file.

        

      4. Now, run the embedded application. The dashboard will be rendered without the error Embed code validation failed, if the error is due to the wrong secret key.
 
Steps to be followed when an issue is due to time difference:
  1. To ensure that the problem Embed code validation failed is caused by a time discrepancy, examine the time of the Bold BI hosting machine and the embedded application hosting machine. If they are different, synchronize both machines' time to resolve the problem.
  2. You can also resolve this error the other way around when your Bold BI server is of version 5.3.53 or later by using the following code sample in the GetDetails API of the embedded application.

public string GetDetails([FromBody] object embedQuerString)

        {

            var embedClass = Newtonsoft.Json.JsonConvert.DeserializeObject<EmbedClass>(embedQuerString.ToString());

            var embedQuery = embedClass.embedQuerString;

            embedQuery += "&embed_user_email=" + EmbedProperties.UserEmail;

          //To set the embed_server_timestamp to overcome the EmbedCodeValidation failing while different timezone using a client application.

            double timeStamp = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;

            embedQuery += "&embed_server_timestamp=" + timeStamp;

            var embedDetailsUrl = "/embed/authorize?" + embedQuery + "&embed_signature=" + GetSignatureUrl(embedQuery);

            using (var client = new HttpClient())

            {

              client.BaseAddress = new Uri(embedClass.dashboardServerApiUrl);

                client.DefaultRequestHeaders.Accept.Clear();

                var result = client.GetAsync(embedClass.dashboardServerApiUrl + embedDetailsUrl).Result;

                string resultContent = result.Content.ReadAsStringAsync().Result;

                return resultContent;

            }

        }


Note: The above code sample is in C# with the highlighted code as a solution, you can use this as a reference to accomplish the same in your embedded application of the corresponding platform.

Related links:




























Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
SM
Written by Soundarya Mani Meharan
Updated
Comments (0)
Please  to leave a comment
Access denied
Access denied