令牌的颁发者不是受信任的颁发者Sharepoint Provider Hosted App

时间:2014-07-23 14:27:11

标签: iis sharepoint certificate sharepoint-apps

我使用以下教程创建了一个应用程序:

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

如果没有sharepoint调用,该应用程序可以正常运行,我的意思是一个带有hello world的response.write。

但是,如果我添加一些共享点,比如打印出用户名,我得到了一个远程服务器返回错误:(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)

1 个答案:

答案 0 :(得分:-1)

您是否在方法上拥有SharePointContextFilterAttribute?该过滤器处理来自请求上下文的认证位。