cli-microsoft365 icon indicating copy to clipboard operation
cli-microsoft365 copied to clipboard

New command: `spo site accessrequest setting set`

Open milanholemans opened this issue 1 year ago • 4 comments

Usage

m365 spo site accessrequest setting set [options]

Description

Update access requests for a specific site

Options

Option Description
-u, --siteUrl <siteUrl> URL of the site collection.
--disabled Disable site requests for the entire site. Specify either disabled, ownerGroup, or email.
--ownerGroup Send access requests to the owner group. Specify either disabled, ownerGroup, or email.
--email [email] Send access requests to a specific email. Specify either disabled, ownerGroup, or email.
--message [message] Add a custom message to the access request page.

Examples

Disable access requests for a specific site.

m365 spo site accessrequest setting set --siteUrl https://contoso.sharepoint.com/sites/Management --disabled

Send all access requests to the owner group of a specific site.

m365 spo site accessrequest setting set --siteUrl https://contoso.sharepoint.com/sites/Management --ownerGroup

Send all access requests to a specific email address and set a custom message.

m365 spo site accessrequest setting set --siteUrl https://contoso.sharepoint.com/sites/Management --email [email protected] --message "Motivate why you need access."

Default properties

N/A

Additional Info

The original idea was created here: https://github.com/pnp/cli-microsoft365/issues/6266

I named this command spo site accessrequest setting set to make it future-proof. In this case, we can still create commands to list all access requests from people on a site, and other commands do approve/decline them.

Let's also make sure we can pass an empty string for message option to clear it.

API

To manage this, there are 3 API requests needed:

Request 1:

PATCH https://contoso.sharepoint.com/sites/Playground/_api/Web
{
    "RequestAccessEmail": "[email protected]"
}

Request 2:

POST https://contoso.sharepoint.com/sites/Playground/_api/Web/SetUseAccessRequestDefaultAndUpdate
{
    "useAccessRequestDefault": false
}

Request 3:

POST https://contoso.sharepoint.com/sites/Playground/_api/Web/SetAccessRequestSiteDescriptionAndUpdate
{
    "description": "Hey you want access? That's $77."
}

When updating access requests, consider the following:

Option used Request 1 value Request 2 value
--disabled "" (empty) false
--ownerGroup "" (empty) true
--email [email protected] [email protected] false

Request 3 should only be used when --message is specified (this isn't possible when using --disabled).

milanholemans avatar Aug 22 '24 20:08 milanholemans

@pnp/cli-for-microsoft-365-maintainers your thoughts on this issue, please?

milanholemans avatar Aug 22 '24 20:08 milanholemans

Very well thought out @milanholemans! Nothing further to add, looks very clear.

Jwaegebaert avatar Aug 23 '24 06:08 Jwaegebaert

May I work on this

ktskumar avatar Sep 25 '24 00:09 ktskumar

Hey @ktskumar, thank you for all the hard work you’ve put in, it’s really appreciated! We’ve noticed that you have several issues assigned that haven't yet been created with a PR To ensure everyone has a chance to get involved, especially with Hacktoberfest, I’ll be unassigning you from some of these issues.

We recommend focusing on 1 to 2 issues at a time. Once you’ve submitted a PR for an issue, you can easily claim another open one. This approach helps you manage the workload more effectively and ensures you can give each task the attention it needs.

Thanks again for your continued contributions!

Jwaegebaert avatar Sep 26 '24 11:09 Jwaegebaert