Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Get-PnPAvailableSensitivityLabel: Access denied. Check for the required permissions #2233

Closed
1 of 6 tasks
YuriySamorodov opened this issue Aug 5, 2022 · 6 comments
Closed
1 of 6 tasks
Labels
bug Something isn't working

Comments

@YuriySamorodov
Copy link
Contributor

Reporting an Issue or Missing Feature

Reporting a bug

Expected behavior

According to the documentation Get-PnPAvailableSensitivityLabel should give Microsoft Purview sensitivity labels in the currently connected tenant

Actual behavior

I am getting an error Access denied. Check for the required permissions whenever I try to run Get-PnPAvailableSensitivityLabel
image

Steps to reproduce behavior

Connect-PnPOnline
Get-PnPAvailableSensitivityLabel

What is the version of the Cmdlet module you are running?

Name    : PnP.PowerShell
Version : 1.11.35

Which operating system/environment are you running PnP PowerShell on?

  • Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify
@YuriySamorodov YuriySamorodov added the bug Something isn't working label Aug 5, 2022
@milanholemans
Copy link
Contributor

milanholemans commented Aug 6, 2022

Hi @YuriySamorodov

According to me, delegated Graph permissions of type InformationProtectionPolicy.Read are needed to make this command work. Currently this permission set is not included yet in the PnP app registration. A PnP Team member should add it.

I also noticed this command uses deprecated Graph endpoints. I made a PR to replace them with the new ones, but you'll still need the permissions listed above to make this work.

@gautamdsheth
Copy link
Collaborator

Thanks @milanholemans for the comment, we will add this permission.
This cmdlet will work as long as your Azure AD app , not the PnP one , has InformationProtectionPolicy.Read delegated permission or InformationProtectionPolicy.Read.All application permission.
Will close the issue now

@oharveyCloudwell
Copy link

Thanks @milanholemans for the comment, we will add this permission. This cmdlet will work as long as your Azure AD app , not the PnP one , has InformationProtectionPolicy.Read delegated permission or InformationProtectionPolicy.Read.All application permission. Will close the issue now

Can you elaborate a little on which app needs to have the permissions? I'm not quite sure what Azure AD app is referring to here. I'm running into the same issue.

@milanholemans
Copy link
Contributor

Hi @oharveyCloudwell

In the back, all PnP apps (PnP PowerShell, M365 CLI, ...) use the same Azure AD app to authenticate to your tenant. Without this app, you don't have permission to query your tenant. You can find this app in Azure AD --> enterprise applications, there search for PnP Office 365 Management Shell. This app lacks the InformationProtectionPolicy.Read permission, PnP maintainers should add this to the app registration (friendly reminder @gautamdsheth, this hasn't happened yet 😊).

You can create your own app registration with your own permissions to work with PnP powershell. In this app registration you can grant the delegated InformationProtectionPolicy.Read permissions yourself. More info on how to create such app can be found here: https://pnp.github.io/powershell/articles/authentication.html

@oharveyCloudwell
Copy link

@milanholemans , thanks for the response. I think I just got around to sorting that out when you responded. I appreciate the information. I agree that it would be easier if this were simply added to the app registration, though.

@milanholemans
Copy link
Contributor

@milanholemans , thanks for the response. I think I just got around to sorting that out when you responded. I appreciate the information. I agree that it would be easier if this were simply added to the app registration, though.

Ok nice to hear it works for you now. I'm confident that this permission will be added to the PnP app registration.
@waldekmastykarz could you add the InformationProtectionPolicy.Read permission to the app registration please?

Much appreciated! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants