Skip to content

Enhancement: Add application permission check to purview retentionlabel and purview retentioneventtype commands #4450

Description

@MathijsVerbeeck

Enhancement:

When executing the purview retentionlabel and purview retentioneventtype get commands, we will get a notification that we do not have the necessary permissions when using application-only permissions.

We should add the following lines in the commandAction of every command and update the tests. We also should add a remark to the docs.

if (accessToken.isAppOnlyAccessToken(auth.service.accessTokens[this.resource].accessToken)) {
      this.handleError('This command does not support application permissions.');
}

Original issue:

Description

Currently, when we execute for example purview retentionlabel list while using application permissions, we will get the following error:
image

After doing some research, I noticed that this was due to me using the application permissions. After logging in using devicecode and a custom app registration with the permission RecordsManagement.ReadWrite.All, it started working

I think that we should add a piece of code that checks if we are using appOnlyAuth and throw an error if this is the case

The error occurs on the following commands

  • purview retentionlabel add
  • purview retentionlabel get
  • purview retentionlabel list
  • purview retentionlabel remove
  • purview retentionlabel set
  • purview retentioneventtype get

Steps to reproduce

  1. Login using --authType secret and a custom application registration
  2. Execute command m365 purview retentionlabel list

Expected results

List of retention labels

Actual results

Error:
image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions