During a recent project we had some weird behavior inviting users to Teams. To have business logic in place we build a custom process to invite external users. Once invited they are added to teams. The weird thing was that when inviting users to the UI they are added as a Guest user to Teams. However once added through our process they are added as a Member according to the UI.
The invite process was straight forward, an FTE could fill in a form and invite an external user to an existing Team, or request a new Team based off a template. Once the Team was created, the invite was sent to the external user and the Azure B2B process was kicked off. Once the external user accepted the invitation, he was prompted with some stuff to sign and only then he would be added to the Team.
The invite process is fully done through the Microsoft Graph. Adding the guest is done through the Graph as well. Turns out that we added the user by issuing a Post to the [groups endpoint]. The only thing we did wrong was adding it as a User Object instead of a Directory Object. So, the body of our request was as follows:
The request does return a 204 no content indicating that all did work. It also adds the user to the team and the user has access, however in the front-end the users are indicated as a member while they should be a guest. Once we changed that to the correct format using the directory object it all went as expected:
Using the Directory Object, the newly invited users are added as a Guest and no longer are shown as Members. It felt a bit weird that we did not get an exception. And everything worked except for a label in the front-end (as far as we could figure out). But then again it makes sense to stick to the documentation and implement it correctly. So, my lesson learned is paying proper attention to the documentation. Double checking the execution and results of Graph requests sounds like my new best practice.
Originally posted at: http://cloudappie.nl/graph-members-guests