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

Bug report: Impossible to create team when using application permissions

Open MathijsVerbeeck opened this issue 1 year ago • 25 comments

Priority

(Low) Something is a little off

Description

It is currently impossible to create a team when using application permissions. This is due to the application permissions request expecting a members property in the request body, and we currently do not demand this.

More information can be found on this URL: https://learn.microsoft.com/en-us/graph/api/team-post?view=graph-rest-1.0&tabs=http#examples

Steps to reproduce

  1. Login using application permissions
  2. Execute m365 teams team add --name 'TEST' --description 'TEST'

Expected results

Team being created or a prompt for members

Actual results

Error: Request failed with status code 400

Diagnostics

Request error:
{
  "url": "https://graph.microsoft.com/v1.0/teams",
  "status": 400,
  "statusText": "Bad Request",
  "headers": {
    "transfer-encoding": "chunked",
    "content-type": "application/json",
    "vary": "Accept-Encoding",
    "strict-transport-security": "max-age=31536000",
    "request-id": "51e35905-5bb0-4c3b-8616-df164c8099e3",
    "client-request-id": "51e35905-5bb0-4c3b-8616-df164c8099e3",
    "x-ms-ags-diagnostic": "{\"ServerInfo\":{\"DataCenter\":\"North Europe\",\"Slice\":\"E\",\"Ring\":\"4\",\"ScaleUnit\":\"003\",\"RoleInstance\":\"DB1PEPF0002D0AB\"}}",
    "date": "Tue, 23 May 2023 09:52:51 GMT",
    "connection": "close"
  }
}

MathijsVerbeeck avatar May 23 '23 10:05 MathijsVerbeeck

Thanks, @MathijsVerbeeck for rising this 👍. We will try to recheck this one ASAP

Adam-it avatar May 23 '23 20:05 Adam-it

Makes sense I guess. I think the only fix here would be to introduce 2 new options

  • --ownerUserId [ownerUserId
  • --ownerUserName [ownerUserName]

Both can be used with delegated or app only auth, but they will be required when using app only auth.

milanholemans avatar May 26 '23 21:05 milanholemans

Makes sense I guess. I think the only fix here would be to introduce 2 new options

  • --ownerUserId [ownerUserId
  • --ownerUserName [ownerUserName]

Both can be used with delegated or app only auth, but they will be required when using app only auth.

I also thought something like that. Makes sense too.

MathijsVerbeeck avatar May 26 '23 21:05 MathijsVerbeeck

Yeah, a team needs at least an owner indeed. We could also add a --memberUserNames option and allow a comma separated string of UPNs... (just like the chat message send command)

martinlingstuyl avatar May 27 '23 09:05 martinlingstuyl

Yeah, a team needs at least an owner indeed. We could also add a --memberUserNames option and allow a comma separated string of UPNs... (just like the chat message send command)

I'd say we start with just specifying a single owner, to at least get this command to work, and we can extend this command in general in the future I believe.

MathijsVerbeeck avatar May 27 '23 18:05 MathijsVerbeeck

Yeah, a team needs at least an owner indeed. We could also add a --memberUserNames option and allow a comma separated string of UPNs... (just like the chat message send command)

I'd say we start with just specifying a single owner, to at least get this command to work, and we can extend this command in general in the future I believe.

I suggest that we decide now if we'd like to support a single- or multiple users, so that we can avoid breaking changes later on. If I for example look at spo site add and aad o365group add, we support --owners [owners]. I suggest we use the same convention here for consistency.

waldekmastykarz avatar Jun 03 '23 07:06 waldekmastykarz

So

  • in delegated mode, when you don't specify --owners, it will add the signed in user.
  • in delegated mode, when you specify --owners, it will add the owners, but not the signed in user if he isn't part of the owners string.
  • in app only mode, --owners is required.

?

martinlingstuyl avatar Jun 03 '23 08:06 martinlingstuyl

What are owners? UPNs? IDs? Usually when we refer to a user we provide an option that accepts UPNs and an option that accepts IDs.

milanholemans avatar Jun 03 '23 10:06 milanholemans

Yes, thinking about that though: why do we even do that? If it's a GUID or an UPN, why don't we verify what kind of value is being used in the CLI? Should be easy to do, and it would clean up a lot of commands with these superfluous options.

martinlingstuyl avatar Jun 03 '23 15:06 martinlingstuyl

I don't know. 😊 Consistency could be an argument. For some commands this won't be that simple, e.g. for aad user get, how do you call an option that accepts both the ID and UPN? Also, some commands accept ID, UPN, and Email, in that case, we cannot tell whether an Email is UPN or a mail.

milanholemans avatar Jun 03 '23 16:06 milanholemans

Any updates regarding this issue?

MathijsVerbeeck avatar Jun 21 '23 13:06 MathijsVerbeeck

Should we add 2 options? ownerUserNames and ownerIds? Which can be used in both delegated and application auth? If we add this, I feel like we should introduce the same options to add members.

milanholemans avatar Jun 21 '23 21:06 milanholemans

Let's do that. And ownerEmails?

martinlingstuyl avatar Jun 22 '23 16:06 martinlingstuyl

Let's do that. And ownerEmails?

Could include that one as well, so do we agree to add the options below?

  • ownerUserNames
  • ownerIds
  • ownerEmails
  • memberUserNames
  • memberIds
  • memberEmails

milanholemans avatar Jun 22 '23 21:06 milanholemans

Perfect. Thank you @martinlingstuyl, @milanholemans for the awesome brainstorm. @MathijsVerbeeck I think we area ready to open this up. Would you like to take the lead?

Adam-it avatar Sep 23 '23 21:09 Adam-it

Perfect. Thank you @martinlingstuyl, @milanholemans for the awesome brainstorm. @MathijsVerbeeck I think we area ready to open this up. Would you like to take the lead?

Sure thing.!

MathijsVerbeeck avatar Sep 23 '23 21:09 MathijsVerbeeck

Awesome 🤩. Please do remember Hacktoberfest starts on 26.09 so if you participate it's best to open the PR after that date 👍

Adam-it avatar Sep 23 '23 21:09 Adam-it

Hi guys

Just some feedback - I came across the following issue: image

Using just a single user works just fine. So it seems that either we have to change the new specs a little bit to allow only one user, or we have to update the team immediately, but then we have to enforce the --wait parameter.

MathijsVerbeeck avatar Sep 25 '23 08:09 MathijsVerbeeck

That's a bummer! I think we should stick to the spec and update the team members afterward.

milanholemans avatar Sep 25 '23 18:09 milanholemans

That's a bummer! I think we should stick to the spec and update the team members afterward.

Sure thing. So I create the team using the first user passed in either one of the owner options and then afterwards patch the team?

MathijsVerbeeck avatar Sep 25 '23 20:09 MathijsVerbeeck

One (hopefully final) further remark I have is that we will have to only include this when using --wait, otherwise the team will most likely not yet be provisioned and it will throw an error.

MathijsVerbeeck avatar Sep 28 '23 14:09 MathijsVerbeeck

good point, I don't think there is any better approach at the moment than enforcing --wait when you want to add multiple owners. Let's make sure that we have good error handling for this scenario and that we add a remark for it as well.

Jwaegebaert avatar Sep 29 '23 06:09 Jwaegebaert

Hey @MathijsVerbeeck, just checking in. What is the latest regarding this issue?

Jwaegebaert avatar Nov 23 '23 13:11 Jwaegebaert

Resetting due to lack of response

waldekmastykarz avatar Jan 14 '24 08:01 waldekmastykarz

Can I restart working on this one?

MathijsVerbeeck avatar Feb 13 '24 20:02 MathijsVerbeeck