The cause of my problem had to do with the way I was implementing the Token Provider for Sitecore Services Client.
- I used Tokens for authenticating Sitecore Services Client
- There is a bug in the SigningTokenProvider - when it tries to log an error, such as the Token being expired, it fails to escape special characters correctly, the write to the log fails, and the site blows up.
So, to replace the SigningTokenProvider, I had to also replace the TokenDelegatingHandler. I made an exact copy of the Sitecore's TokenDelegatingHandler, except that it instantiates my SigningTokenProvider instead of Sitecore's. I replaces Sitecore's Token DelegatingHandler with a patch file:
<patch:attribute name="value">Sitecore.Services.Infrastructure.Web.Http.Security.ServicesOnPolicy, Sitecore.Services.Infrastructure</patch:attribute>
<signingProvider type="Sitecore.Services.Infrastructure.Sitecore.Security.SymetricKeySigningProvider, Sitecore.Services.Infrastructure.Sitecore">
<configuration type="Sitecore.Services.Infrastructure.Configuration.ServicesConfiguration, Sitecore.Services.Infrastructure">
<allowedController desc="EnglishController">DD.Services.Controller.SiteSpecific.XfinityPrepaidDotNet.EnglishPageRepository, DD.Services</allowedController>
<allowedController desc="SpanishController">DD.Services.Controller.SiteSpecific.XfinityPrepaidDotNet.SpanishPageRepository, DD.Services</allowedController>
<delegatingHandlers hint="list:AddDelegatingHandler" patch:instead="delegatingHandlers">
The problem here is that there is another bug in Sitecore that if I log in this way, even when I log in, my user is returned as not authenticated:
So I started messing around with the validation in the TokenDelegatingHandler. What I didnt realize is that a whole bunch of the Analytics parts of Sitecore use this TokenDelegatingHandler to connect. When I changed this, I broke all sorts of analytics components, including whatever was generating that error.
- So, I reverted the TokenDelegatingHandler to be just a copy of Sitecore's except that it calls my SiginingTokenProvider. And my SigningTokenProvider is an exact copy of Sitecore's, except that it handles the errors correctly.
This seemed to eliminate the error. Then I had to move my custom logic that deals with the IsAuthorized problem to an AuthorizationFilterAttribute.