I've been working on upgrading a WebForms application to use Azure AD. I've registered the app, and provided the ClientID and TenantID to the application. I've done this upgrade to several apps already with minimal difficulty.
There is a routine I don't quite understand which is trying to get JSON from the server. It apparently has something to do with OpenID. However, the URL used to retrieve it keeps erroring out, saying it can't locate the document.
If I paste the URL with config info into a browser though, it returns the json just fine. However, the application throws an exception. The error is IDX20804, Unable to retrieve document.The _metaAddress is an URL I can paste in a browser and retrieve the json successfully.
Does anyone have a suggestion on how to even troubleshoot this?
Following is the code. The exception is thrown on the line beginning "_currentConfiguration = "
public async Task<T> GetConfigurationAsync(CancellationToken cancel)
{
DateTimeOffset now = DateTimeOffset.UtcNow;
if (_currentConfiguration != null && _syncAfter > now)
{
return _currentConfiguration;
}
await _refreshLock.WaitAsync(cancel);
try
{
if (_syncAfter <= now)
{
try
{
// Don't use the individual CT here, this is a shared operation that shouldn't be affected by an individual's cancellation.
// The transport should have it's own timeouts, etc..
_currentConfiguration = await _configRetriever.GetConfigurationAsync(_metadataAddress, _docRetriever, CancellationToken.None).ConfigureAwait(false);
Contract.Assert(_currentConfiguration != null);
_lastRefresh = now;
_syncAfter = DateTimeUtil.Add(now.UtcDateTime, _automaticRefreshInterval);
}
catch (Exception ex)
{
_syncAfter = DateTimeUtil.Add(now.UtcDateTime, _automaticRefreshInterval < _refreshInterval ? _automaticRefreshInterval : _refreshInterval);
throw LogHelper.LogExceptionMessage(new InvalidOperationException(LogHelper.FormatInvariant(LogMessages.IDX20803, (_metadataAddress ?? "null")), ex));
}
}
// Stale metadata is better than no metadata
if (_currentConfiguration != null)
return _currentConfiguration;
else
{
throw LogHelper.LogExceptionMessage(new InvalidOperationException(LogHelper.FormatInvariant(LogMessages.IDX20803, (_metadataAddress ?? "null"))));
}
}
finally
{
_refreshLock.Release();
}
}
Thanks for any ideas.