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

New command: m365 spe containertype register #6049

Open
Adam-it opened this issue May 12, 2024 · 7 comments
Open

New command: m365 spe containertype register #6049

Adam-it opened this issue May 12, 2024 · 7 comments
Labels
needs peer review Needs second pair of eyes to review the spec or PR new feature

Comments

@Adam-it
Copy link
Contributor

Adam-it commented May 12, 2024

Usage

m365 spe containertype register [options]

Description

Register the Container Type

Options

Option Description
-i, --id [id] The Id of the Container Type. Specify either id or name but not both.
-n, --name [name] The Container Type name. Specify either id or name but not both.

Examples

Register the Container Type using name

m365 spe containertype register --id '4ec4aefd-4fa3-0e4a-20c3-6e68389e7138'

Register the Container Type using id

m365 spe containertype register --name 'test container'

Default properties

No response

Additional Info

we may use the SharePoint REST PUT request

{{RootSiteUrl}}/_api/v2.1/storageContainerTypes/{{ContainerTypeId}}/applicationPermissions

with the following body

{
    "value": [
        {
            "appId": "{{ClientID}}",
            "delegated": ["full"],
            "appOnly": ["full"]
        }    ]
}

@Adam-it Adam-it added new feature needs peer review Needs second pair of eyes to review the spec or PR labels May 12, 2024
@milanholemans
Copy link
Contributor

Hi @Adam-it, few questions

  • I find it a bit tricky to execute this request on the root URL of the SharePoint tenant. This would mean that the user needs permission to this site right? I see it's displayed like this in the docs, so maybe there is no other way to do this?
  • Looking at the docs, it seems like we have to provide a request body with app ID and permission scopes. Don't we need additional options for this?
PUT https://contoso.sharepoint.com/_api/v2.1/storageContainerTypes/{containerTypeId}/applicationPermissions
Content-Type: application/json

{
  "value": [
    {
      "appId": "71392b2f-1765-406e-86af-5907d9bdb2ab",
      "delegated": ["full"],
      "appOnly": ["full"]
    }
  ]
}

@intikhabalam
Copy link

i am unable to use this, i am getting following errors.

PS C:\Users\IntikhabA\Downloads\abc> m365 spe containertype register --id 'a07be3cc-91fb-45d1-9564-77d2a9ac7be3'
Command 'spe containertype register' was not found. Below you can find the commands and command groups you can use. For detailed information on a command group, use 'm365 [command group] --help'.
image

do i need to install something new?

@MathijsVerbeeck
Copy link
Contributor

@intikhabalam That is because the command still has to be implemented and not available for use just yet.

@intikhabalam
Copy link

i am stuck with a production level problem. can you any one give me any easy way to register my containerType with azure entra app registration?

@Adam-it
Copy link
Contributor Author

Adam-it commented Jun 2, 2024

i am stuck with a production level problem. can you any one give me any easy way to register my containerType with azure entra app registration?

sorry @intikhabalam for the late reply.
In order to register Container Type with the consumer’s tenant you need to use SharePoint Rest v2.1 for that.
you may use the following endpoint {{RootSiteUrl}}/_api/v2.1/storageContainerTypes/{{ContainerTypeId}}/applicationPermissions
which is a PUT request with the following body

{
    "value": [
        {
            "appId": "{{ClientID}}",
            "delegated": ["full"],
            "appOnly": ["full"]
        }
    ]
}

Please be aware for in order for this to work you will need to use application authentication method with cert.

Check out the SharePoint Embedded Sample Apps. There you will find a postman collection which will give you everything you need to set up and get started with SPE.
You may find this request in the collection as well.

image

for a more comprehensive overview which also explains the registration I highly recommend AC blog post
https://www.voitanos.io/blog/sharepoint-embedded-create-apps/#register-container-type-in-consumer-tenant

Hope it helps and allows you to move forward

@Adam-it
Copy link
Contributor Author

Adam-it commented Jun 2, 2024

  • Looking at the docs, it seems like we have to provide a request body with app ID and permission scopes. Don't we need additional options for this?

thanks @milanholemans for pointing it out. I kinda assumed it is just common knowledge and probably was in a bit of a hurry. I updated the docs

  • I find it a bit tricky to execute this request on the root URL of the SharePoint tenant. This would mean that the user needs permission to this site right? I see it's displayed like this in the docs, so maybe there is no other way to do this?

this request should be run as an app

@intikhabalam
Copy link

intikhabalam commented Jun 2, 2024

thank you @milanholemans , @MathijsVerbeeck for reply, I tried both ways but getting 'access denied' error. I am a bit confused about the body of Registration ContainerType also. it contains a section for graph explorer AppId also.
{
"value": [
{
"appId": "a07be3cc-91fb-45d1-9564-77d2a9ac7be3",
"delegated": ["full"],
"appOnly": ["full"]
},
{
/*
This adds the Graph Explorer AppId to your Container Type with full permmissions
on delegated access. Note that you cannot create Containers with Graph Explore as
those calls must be made with a confidential client, and Graph Explorer only creates
public client tokens. But other APIs, include the Drive and DriveItem related calls,
should work.
*/
"appId": "de8bc8b5-d9f9-48b1-a8ad-b748da725064", // Graph Explorer AppId
"delegated": ["full"],
"appOnly": ["none"] //Graph Explorer only supports delegated auth
}
]
}

image

i have tried with or without graph App Id but i get the error for all calls :( I followed the viotanos and microsoft SPE article but getting failure always :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs peer review Needs second pair of eyes to review the spec or PR new feature
Projects
None yet
Development

No branches or pull requests

4 participants