diff --git a/BlazorWebAssembly/Client/wwwroot/index.html b/BlazorWebAssembly/Client/wwwroot/index.html
index ba2f17e..5cc8d0b 100644
--- a/BlazorWebAssembly/Client/wwwroot/index.html
+++ b/BlazorWebAssembly/Client/wwwroot/index.html
@@ -1,5 +1,6 @@
+
@@ -28,7 +29,10 @@
+
\ No newline at end of file
diff --git a/BlazorWebAssembly/Server/Controllers/EmbedDataController.cs b/BlazorWebAssembly/Server/Controllers/EmbedDataController.cs
index dbaa596..32dc6fe 100644
--- a/BlazorWebAssembly/Server/Controllers/EmbedDataController.cs
+++ b/BlazorWebAssembly/Server/Controllers/EmbedDataController.cs
@@ -1,13 +1,7 @@
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http;
-using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using BlazorWebAssembly.Shared;
-using BlazorWebAssembly.Client.Pages;
+using System.Text;
namespace BlazorWebAssembly.Server.Controllers
{
@@ -42,38 +36,32 @@ public IActionResult EmbedConfigErrorLog()
}
[HttpPost("[action]")]
- [Route("AuthorizationServer")]
- public string AuthorizationServer([FromBody] object embedQuerString)
+ [Route("TokenGeneration")]
+ public string TokenGeneration()
{
- var embedClass = JsonConvert.DeserializeObject(embedQuerString.ToString());
- var embedQuery = embedClass.embedQuerString;
- embedQuery += "&embed_user_email=" + GlobalAppSettings.EmbedDetails.UserEmail;
- //To set embed_server_timestamp to overcome the EmbedCodeValidation failing while different timezone using at 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())
+ var embedDetails = new
{
- client.BaseAddress = new Uri(embedClass.dashboardServerApiUrl);
- client.DefaultRequestHeaders.Accept.Clear();
+ email = GlobalAppSettings.EmbedDetails.UserEmail,
+ serverurl = GlobalAppSettings.EmbedDetails.ServerUrl,
+ siteidentifier = GlobalAppSettings.EmbedDetails.SiteIdentifier,
+ embedsecret = GlobalAppSettings.EmbedDetails.EmbedSecret,
+ dashboard = new // Dashboard ID property is mandatory only when using BoldBI version 14.1.11.
+ {
+ id = GlobalAppSettings.EmbedDetails.DashboardId
+ }
+ };
+
+ //Post call to Bold BI server
+ var client = new HttpClient();
+ var requestUrl = $"{embedDetails.serverurl}/api/{embedDetails.siteidentifier}/embed/authorize";
- var result = client.GetAsync(embedClass.dashboardServerApiUrl + embedDetailsUrl).Result;
- string resultContent = result.Content.ReadAsStringAsync().Result;
- return resultContent;
- }
- }
+ var jsonPayload = JsonConvert.SerializeObject(embedDetails);
+ var httpContent = new StringContent(jsonPayload, Encoding.UTF8, "application/json");
- public string GetSignatureUrl(string message)
- {
- var encoding = new System.Text.UTF8Encoding();
- var keyBytes = encoding.GetBytes(GlobalAppSettings.EmbedDetails.EmbedSecret);
- var messageBytes = encoding.GetBytes(message);
- using (var hmacsha1 = new System.Security.Cryptography.HMACSHA256(keyBytes))
- {
- var hashMessage = hmacsha1.ComputeHash(messageBytes);
- return Convert.ToBase64String(hashMessage);
- }
+ var result = client.PostAsync(requestUrl, httpContent).Result;
+ var resultContent = result.Content.ReadAsStringAsync().Result;
+
+ return JsonConvert.DeserializeObject(resultContent).Data.access_token;
}
}
}
diff --git a/images/dashboard.png b/images/dashboard.png
index eb0cb22..7f357cb 100644
Binary files a/images/dashboard.png and b/images/dashboard.png differ