1

I get a 403 error when i try to check if a user is part of group.

 let props = this.properties;
  let GroupsArray: string[] = [];

  if (props.Groups != null && props.Groups.length > 0) {
    GroupsArray = props.Groups.split(',');
  }
sp.web.siteGroups.getByName(GroupsArray[0]).users.get().then((users) => {
    if (users.filter(i => i.Email == currentUser).length > 0) {
      IsvalidGroup = true;
      this.getBenefitsList(GroupsArray[0]);
    } else {
      IsvalidGroup = false;
    }
  }).then(()=>{
    if (!IsvalidGroup) {
      sp.web.siteGroups.getByName(GroupsArray[1]).users.get().then((users)=>{
        if (users.filter(i => i.Email == currentUser).length > 0) {
          IsvalidGroup = true;
          this.getBenefitsList(GroupsArray[1]);
        }   
      })
    }
  }).catch(err => {
    this.SetError(err);
     console.log(err); }
  )
  return IsMember;

Below is the error

Error: Error making HttpClient request in queryable [403] ::> {"odata.error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"en-US","value":"Access denied. You do not have permission to perform this action or access this resource."}}}
2

You should check if, in the settings of the group, the Who can view the membership of the group? is set to Everyone. It is probably set to Group Members so you should change it to Everyone.

You can check that setting by going to https://SITEURL/_layouts/15/user.aspx , then clicking on group name and choosing the menu item Settings -> Group settings.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.