Can you try to pass any other requestURL instead of the current request URL and then check the behaviour?
Issue #1: Tried passing other request URL's as well, but the looping is happening...
Issue #2: BuildContent() Method's parameter (object value) always provides the Error response code as "Unauthorized"
Also,Could you please confirm whether "ContentResultService" is the wrapper function where we used to perform HTTPWebRequest and HTTPWebResponse, if not kindly provide us the right wrapper function where we could make use of these content REST API Calls?
Hi,
ContentResultService is responsible for serializing the content and put it in a StringContent object before it's served in the web API. It's still a bit unclear what you're acutally trying to achieve here.
What is the goal? To protect the Content Delivery API with OpenID Connect and use Okta for authenticating users, then the users should be able to call the Content Delivery API with the access token they received when logging in through Okta?
Hi,
Here we have resolved our issue by,
Implementing "CustomContentAPIAuthorizationService" which inherits "ContentAPIAuthorizationService". Then need to add the created CustomContentAPIAuthorizationService in DependencyResolverInitialization.cs. With this, we resolved our Issue #1: Looping issue.
Please refer the below links for more details:
https://developer.okta.com/code/dotnet/jwt-validation/
https://krompaco.nu/2018/12/content-delivery-api-and-custom-authorization/
Let us know if there is any other best approaches.
Thanks,
Sangeetha
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.