Search code examples
microsoft-graph-apimicrosoft-graph-teams

How to redeem an invitation with Microsoft Graph?


I have existed users in my DB with the email already validated. I would like to invite them as Guest to our Azure Active Directory to make them able to chat on teams using Azure Communication Services.

        var invitation = new Invitation
        {
            InvitedUserEmailAddress = userModel.Email,
            InvitedUser = new User
            {
                GivenName = userModel.Firstname,
                Surname = userModel.Lastname,
                DisplayName = $"{userModel.Firstname} {userModel.Lastname}",
                Mail = userModel.Email,
                UserType = "Guest", // Member
                OtherMails = new List<string> { userModel.Email },
                Identities = new List<ObjectIdentity>
        {
            new ObjectIdentity
            {
                SignInType = "emailAddress",
                Issuer = "Unknow",
                IssuerAssignedId = userModel.Email
            },
        },
                PasswordPolicies = "DisablePasswordExpiration"
            },
            SendInvitationMessage = false,
            InviteRedirectUrl = redirectUrl.ToString(),
            InvitedUserType = "guest" // default is guest,member
        };
        var invite = await Client.Invitations.PostAsync(invitation);

First I thought that calling the redeemUrl returned by Microsoft could work:

        await _httpClient.GetAsync(invite.InviteRedeemUrl)

I have a 200 code returned, but the use is still in pending status.

How can I redeem the invitation by code using Microsoft Graph?

Thanks


Solution

  • According to the documentation, there is no API to perform the redemption process.

    The invited user has to go through the interactive redemption process in a browser. Calling inviteRedeemUrl through HttpClient has no effect on the redemption process. The invited user has to sign-in and authenticate.

    According to this, automatic redemption is currently in preview, so I don't expect that Graph API will support it soon.