Invite External Guest to Teams Using Graph API and Power Automate

In this article I will be explaining how to do an external guest invite through Graph API and power automate , this power automate flow can be invoked from a Microsoft form or from a sharepoint list or whatever you find applicable and the same procedures applies if you want to share your PowerApps canvas app with external Guests as well or give access to sharepoint site.

Step 1: Create App Registration in AD to be able to access the GRAPH API

  1. Login to Azure AD https://aad.portal.azure.com/
  2. Go to App Registrations and click on New Registration
  3. Give it a proper name so that you can identify it, Add the redirect URL to be the Link to your team and click Register.

4. Go to API Permissions and add User.Invite All and then Grant admin consent

Add Permission
Grant Admin Consent

To Get LINK to your Team -> Go to Teams and right click on the channel and click Get Link To Team

3. Generate Client Secret and copy it aside

New Client Secret
Copy Client Secret

4. Copy Tenant ID as well

Step 3: Manual Flow for the article purpose that takes an Input the User Email and Sends out the invitation.

  1. Create a new flow with an Input called “External User Email”

2. Add a compose Action for your teams URL as below

3. Call Graph API using HTTP Action

Parameters:

Method: Post

URI: https://graph.microsoft.com/v1.0/invitations

Body:


{
  "invitedUserEmailAddress": "yyy@test.com",
  "sendInvitationMessage":true,
  "inviteRedirectUrl": "https://myapp.contoso.com"
}

Authentication: Active Directory OAuth

Tenant: Tenant ID you have copied

Audience: https://graph.microsoft.com

Client ID: Client ID you have copied

Credential Type : Secret

Client Secret: Secret you copied before

4. You need then to get the invited User Id, so add a compose data operation with the below expression

body('HTTP')?['invitedUser']?['id']

5. Then use the Add Member to Group to add the user to your Team channel Group

Now Time to test your flow : I added my personal email to the Input parameter

By Checking my personnel email , I get the below email

And by going to my Team i found me added as a Guest

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website with WordPress.com
Get started
%d bloggers like this: