Эмитент токена не является доверенным эмитентом Размещенное приложение Sharepoint Provider

Я создал приложение, используя следующий учебник:

http://www.luisevalencia.com/2014/07/23/prepare-environments-sharepoint-provider-hosted-apps/

Приложение отлично работает, если нет вызовов sharepoint, я имел в виду, что работает response.write with hello world.

Но, если я добавлю некоторые вещи в sharepoint, такие как распечатка имени пользователя, я получаю Удаленный сервер вернул ошибку: (401) Неавторизованный.

Uri hostWeb = new Uri(Request.QueryString["SPHostUrl"]);

            using (var clientContext = TokenHelper.GetS2SClientContextWithWindowsIdentity(hostWeb, Request.LogonUserIdentity))
            {
                clientContext.Load(clientContext.Web, web => web.Title);
                clientContext.ExecuteQuery();
                Response.Write(clientContext.Web.Title);
                Response.Write("Hello World");

            }

Я получаю следующую ошибку в журналах.

SPApplicationAuthenticationModule: Failed to authenticate request, unknown error. Exception details: System.IdentityModel.Tokens.SecurityTokenException: The issuer of the token is not a trusted issuer.    
 at Microsoft.SharePoint.IdentityModel.SPTrustedIssuerNameRegistry`1.GetIssuerName(SecurityToken securityToken, String requestedIssuerName)    
 at Microsoft.SharePoint.IdentityModel.SPJsonWebSecurityBaseTokenHandler.GetIssuerNameFromIssuerToken(JsonWebSecurityToken token)    
 at Microsoft.SharePoint.IdentityModel.SPJsonWebSecurityBaseTokenHandler.GetIssuerName(JsonWebSecurityToken token)    
 at Microsoft.IdentityModel.S2S.Tokens.JsonWebSecurityTokenHandler.ValidateTokenCore(SecurityToken token, Boolean isActorToken)    
 at Microsoft.IdentityModel.S2S.Tokens.JsonWebSecurityTokenHandler.ValidateTokenCore(SecurityToken token, Boolean isActorToken)    
 at Microsoft.SharePoint.IdentityModel.SPJsonWebSecurityBaseTokenHandler.ValidateToken(SecurityToken token)    
 at Microsoft.SharePoint.IdentityModel.SPJsonWebSecurityTokenHandler.ValidateToken(SecurityToken token)    
 at Microsoft.SharePoint.IdentityModel.SPApplicationAuthenticationModule.TryExtractAndValidateToken(HttpContext httpContext, SPIncomingTokenContext& tokenContext)    
 at Microsoft.SharePoint.IdentityModel.SPApplicationAuthenticationModule.ConstructIClaimsPrincipalAndSetThreadIdentity(HttpApplication httpApplication, HttpContext httpContext, SPFederationAuthenticationModule fam)    
 at Microsoft.SharePoint.IdentityModel.SPApplicationAuthenticationModule.AuthenticateRequest(Object sender, EventArgs e)

person Luis Valencia    schedule 23.07.2014    source источник
comment
Я полагаю, что я сделал что-то не так с сертификатом, созданием или импортом.!   -  person Luis Valencia    schedule 23.07.2014
comment
У Стива Пешки есть отличные советы и рекомендации по устранению неполадок здесь: blogs.technet.com/b/speschka/archive/2012/11/01/   -  person Danny Jessee    schedule 24.07.2014


Ответы (1)


У вас есть SharePointContextFilterAttribute в методе? Этот фильтр обрабатывает биты аутентификации из контекста запроса.

person Trevor Germain    schedule 23.10.2015