azure-active-directoryoffice365powerappspowerapps-formula

Power Apps error ""Office365Groups.ListGroups Failed Authorization_RequestDenied""


I have this code inside the OnSelect property of a button inside Power Apps canvas application, to get the members of a security group:-

Set(
    wAdminID1_1,
    LookUp(
        Office365Groups.ListGroups({'$filter': "startswith(displayName," & "'PPM'" & ")"}).value,
        displayName = varITMGGroupName
    ).id
);

now this is working well for me as i am the admin, but for an external user , the user is getting this error:-

johnjohnPter_0-1706399586256.png

so not sure is this error related to that the user is external or that the user is not admin?

the group is a security group without email, as follow:-

sg.PNG

any advice?


Solution

  • The error "Insufficient privileges" usually occurs if the user does not have required permissions or roles to perform the operation.

    Usually, external users have limited access to directory objects and will get same error from Portal too:

    enter image description here

    In your case, check below settings to know what access guest users currently have:

    enter image description here

    To resolve the error, they should be assigned with proper administrator role like this:

    enter image description here

    After assigning the role, external user can access the group without any error:

    enter image description here

    Similarly, I used below code in OnSelect property of buttons inside Power Apps canvas application after assigning role and got response like this:

    Get Group ID:

    Set(
        wAdminID1_1,
        LookUp(
            Office365Groups.ListGroups({'$filter': "startswith(displayName,'PPM-Accounting Team')"}).value,
            true 
        ).id
    );
    

    List Group members:

    ClearCollect(MembersfromSG,Office365Groups.ListGroupMembers(wAdminID1_1).value)
    

    Response:

    enter image description here