Guest User

Untitled

a guest
Nov 17th, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. System.IdentityModel.Tokens.SecurityTokenValidationException: The token being parsed does not have an issuer.
  2. at Microsoft.IdentityModel.S2S.Tokens.JsonWebSecurityTokenHandler.ReadTokenCore(String token, Boolean isActorToken)
  3. at Microsoft.IdentityModel.S2S.Tokens.JsonWebSecurityTokenHandler.ReadToken(String token)
  4.  
  5. WebHeaderCollection headers = WebOperationContext.Current.IncomingRequest.Headers;
  6.  
  7. string contextTokenSting = headers["S2SSecurityContext"];
  8.  
  9. SharePointContextToken contextToken = TokenHelper.ReadAndValidateContextToken(contextTokenSting, sharepointUrl.Authority);
  10.  
  11. string accessToken = TokenHelper.GetAccessToken(contextToken, sharepointUrl.Authority).AccessToken;
  12.  
  13. ClientContext clientContext = TokenHelper.GetClientContextWithAccessToken(sharepointUrl.ToString(), accessToken);
  14.  
  15. Web web = clientContext.Web;
  16. File file = web.GetFileByServerRelativeUrl(serverrelative);
  17. clientContext.Load(file);
  18. clientContext.ExecuteQuery();
  19.  
  20. string realm = TokenHelper.GetRealmFromTargetUrl(sharepointUrl);
  21.  
  22. string accessToken = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, sharepointUrl.Authority, realm).AccessToken;
  23.  
  24. using (var clientContext = TokenHelper.GetClientContextWithAccessToken(sharepointUrl.ToString(), accessToken))
  25. {
  26. //Do your operation
  27. }
Add Comment
Please, Sign In to add comment