Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- System.IdentityModel.Tokens.SecurityTokenValidationException: The token being parsed does not have an issuer.
- at Microsoft.IdentityModel.S2S.Tokens.JsonWebSecurityTokenHandler.ReadTokenCore(String token, Boolean isActorToken)
- at Microsoft.IdentityModel.S2S.Tokens.JsonWebSecurityTokenHandler.ReadToken(String token)
- WebHeaderCollection headers = WebOperationContext.Current.IncomingRequest.Headers;
- string contextTokenSting = headers["S2SSecurityContext"];
- SharePointContextToken contextToken = TokenHelper.ReadAndValidateContextToken(contextTokenSting, sharepointUrl.Authority);
- string accessToken = TokenHelper.GetAccessToken(contextToken, sharepointUrl.Authority).AccessToken;
- ClientContext clientContext = TokenHelper.GetClientContextWithAccessToken(sharepointUrl.ToString(), accessToken);
- Web web = clientContext.Web;
- File file = web.GetFileByServerRelativeUrl(serverrelative);
- clientContext.Load(file);
- clientContext.ExecuteQuery();
- string realm = TokenHelper.GetRealmFromTargetUrl(sharepointUrl);
- string accessToken = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, sharepointUrl.Authority, realm).AccessToken;
- using (var clientContext = TokenHelper.GetClientContextWithAccessToken(sharepointUrl.ToString(), accessToken))
- {
- //Do your operation
- }
Add Comment
Please, Sign In to add comment