I'm using the prismicio.netstandard library from the nuget package in a server-side blazor app. For some reason, when I try to get an API reference using the "DefaultPrismicApiAccessor" class, the call to the GetApi method never returns.
I was able to get it to work once only, but after that is just stopped working.
I'm not sure if I'm using the library incorrectly as I am new to prismic, and I haven't been able to find any good examples/documentation on how to use the prismicio.netstandard library. I also tried using the older "prismicio" nuget package, but that has the same result, getting an API reference just hangs.
Here's my current code:
private prismic.Api PrismicAPI
{
get
{
if (_apiAccessor == null)
{
var cookieContainer = new CookieContainer();
var httpClientHandler = new HttpClientHandler
{
AllowAutoRedirect = true,
UseCookies = true,
//TODO: CheckCertificateRevocationList = true,
AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip,
SslProtocols = System.Security.Authentication.SslProtocols.Tls12 | System.Security.Authentication.SslProtocols.Tls13,
CookieContainer = cookieContainer
};
var httpClient = new HttpClient(httpClientHandler);
var httpClientLogger = _loggerFactory.CreateLogger<PrismicHttpClient>();
var apiLogger = _loggerFactory.CreateLogger<prismic.Api>();
var httpContextAccessor = new HttpContextAccessor();
var memoryCache = new Microsoft.Extensions.Caching.Memory.MemoryCache(new Microsoft.Extensions.Caching.Memory.MemoryCacheOptions());
var inMemoryCache = new prismic.InMemoryCache(memoryCache);
var prismicHttpClient = new prismic.PrismicHttpClient(httpClient, inMemoryCache, httpClientLogger);
_apiAccessor = new DefaultPrismicApiAccessor(prismicHttpClient, apiLogger, inMemoryCache, httpContextAccessor);
}
//this call hangs and never returns:
var prismicAPI = _apiAccessor.GetApi(apiEndpoint, permanentAccessToken).Result;
return prismicAPI;
}
}
I would appreciate if anyone have any suggestions/recommendations on what may be wrong here.