Hello All,
We are trying to implement the token validation using JWT Security Token and we were able to successfully generate the token.
Based on the token validation we are trying to retrieve the Content API Results, but the issue we are facing is as follows:
We found that "ContentResultService" is the wrapper function where we were able to fetch the request url and other data 's from the request URL.
But while trying to get the HttpWebResponse from the request URL, it is looped (it hits the start of BuildContent() ) and we are unable to get the response.
[ServiceConfiguration(typeof(ContentResultService))]
public class CustomContentResultService : ContentResultService
{
public CustomContentResultService(IContentApiSerializer contentApiSerializer) : base(contentApiSerializer)
{
}
public override StringContent BuildContent(object value)
{
string token = "some_token";
bool hasValue = PageHelper.TokenValidation(token);
if (hasValue)
{
var requestURL = HttpContext.Current.Request.Url.ToString();
string response = string.Empty;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestURL);
request.Method = "GET";
request.ContentType = "application/json";
request.Headers.Add("Accept-Language", "en");
request.Headers.Add("Authorization", "Bearer " + token);
HttpWebResponse webResponse = (HttpWebResponse)request.GetResponse();
}
}
Kindly provide your suggestions to resolve this issue.