Microsoft Graph API Groups and Collaboration
This connector facilitates the management of groups and collaboration settings within Microsoft 365 through the Microsoft Graph API, enabling automated workflows for group administration and user collaboration.
Microsoft Graph API is a unified gateway to data and intelligence in Microsoft 365, providing access to rich, people-centric data and insights exposed as resources in Microsoft Graph. The Groups and Collaboration connector allows Swimlane Turbine users to automate group management and collaboration workflows. It enables the addition of members to groups, management of rejected senders, and streamlines collaboration across Microsoft services. This integration empowers security teams to maintain group integrity and manage collaboration settings efficiently, enhancing organizational security posture with minimal manual intervention.
Configuration
Prerequisites
To utilize the Microsoft Graph API Groups and Collaboration connector, ensure you have the following prerequisites:
- Client Credentials and Tenant ID authentication with these parameters:
- URL: Endpoint for Microsoft Graph API
- Client ID: Application identifier registered with Azure AD
- Client Secret: Confidential string used to establish app identity
- Tenant ID: Directory identifier in Azure AD
- Scope: Permissions the app requires
- OAuth 2.0 Client Credentials with these parameters:
- URL: Endpoint for Microsoft Graph API
- Client ID: Application identifier registered with Azure AD
- Client Secret: Confidential string used to establish app identity
- Token URL: URL to obtain the access token
- Scope: Permissions the app requires
- Delegated Flow Authentication with these parameters:
- URL: Endpoint for Microsoft Graph API
- Tenant ID: Directory identifier in Azure AD ... and so on
Authentication Methods
OAuth 2.0 client credentials authentication with these parameters:
- url: Endpoint for Microsoft Graph API.
- client_id: Application (client) ID registered in Azure AD.
- client_secret: Client secret (key) generated for the application in Azure AD.
- token_url: URL to retrieve the OAuth token.
- scope: Permissions the app requires.
Password Grant (Delegated Authentication) for acting on behalf of a user:
- url: Endpoint for Microsoft Graph API.
- tenant_id: Directory ID of the Azure AD tenant.
- oauth_un: User's username to authenticate.
- oauth_pwd: User's password to authenticate.
- oauth_cl_id: Application (client) ID registered in Azure AD.
- oauth_cl_secret: Client secret (key) generated for the application in Azure AD.
- login_url: Login URL. Default value is https://login.microsoftonline.com. (Optional).
- scope: Permissions the app requires. Optional field. (Optional).
Asset credentials specific to your organization (Microsoft Graph API Asset - Tenant ID):
- url: Endpoint for Microsoft Graph API.
- client_ID: Application (client) ID registered in Azure AD.
- client_Secret: Client secret (key) generated for the application in Azure AD.
- tenant_id: Directory ID of the Azure AD tenant.
- scope: Permissions the app requires.
Authentication for OAuth2 Refresh Token Grant credentials for Microsoft Graph API authentication
- url: Endpoint for Microsoft Graph API.
- client_ID: Application (client) ID registered in Azure AD.
- client_Secret: Client secret (key) generated for the application in Azure AD.
- refresh_token: Refresh Token.
- scope: Permissions the app requires.
Capabilities
The Microsoft Graph API connector gives the ability to get and update security alerts, and modify user licenses and sessions.
- Add Members
- Create RejectedSender
Asset Setup
Client Credential Flow Authentication
Authentication uses Azure application OAuth2. You will need an admin account in Azure to create the application.
Recommended Application Permissions (feel free use custom permissions if you only use certain actions):
- User.ReadWrite.All
- Directory.ReadWrite.All
- Directory.AccessAsUser.All
- Group.ReadWrite.All
- IdentityRiskyUser.Read.All
In order to set up the asset, you need the following:
- Azure Application Client ID
- Azure Application Client Secret
- Azure Tenant ID
Steps to create the Azure app:
- Go to the App Registration page in the Azure portal.
- Click New Registration.
- Enter a name for your new application and choose Accounts in this organizational directory only, then click Register at the bottom.
- Navigate to the API permissions tab on the left navigation menu.
- Select Add a permission.
- Select Microsoft Graph.
- Select Application permissions, then mark all the permissions you need for the actions you are using (See suggested permissions at the top of the asset setup section).
- Click the Add permissions button at the bottom of the page.
- Select Grant admin consent for your organization, then your permissions should look as below.
- Navigate to the Certificates & secrets tab and select New client secret.
- Fill out the description and expiration, then click the Add button at the bottom.
- The Value of the secret you just created is the Client Secret needed for the Swimlane asset.
- Navigate to the Overview tab on the left menu.
- The Client ID and Tenant ID needed in the asset are shown on this page.
The Client ID, Tenant ID, and Client Secret described in the steps above are the credentials you need for the asset.
Password Flow (Delegated Auth)
- Use Delegated Permissions, instead of Application Permissions, and generate Client ID, Tenant ID, and Client Secret as described in the above Client Credential Flow Authentication.
- We also need an Username and a Password for this authentication.
Authentication flow for OAuth2 Refresh Token
- Oauth 2.0 refresh token grant, which requires a Refresh Token,Tenant ID, Client ID and Client Secret. Use this auth with accounts which have MFA enabled. To generate a refresh token please follow the instructions below.
- In step 3 of the above-mentioned setup instructions, please provide a Redirect URI and select the platform as 'Web', before clicking on Register at the the bottom.
- Proceed with the remaining steps to generate 'Client ID', Tenant ID and Client Secret.
- Add the permissions in Delegated Permissions.
- The Swimlane team will provide a Python script and instructions on how to use the script to generate the Refresh Token.
Limit Access to specific mailboxes
Administrators who want to limit app access to specific mailboxes can create an application access policy by using the New-ApplicationAccessPolicy PowerShell cmdlet. For more information please see the article Limiting application permissions to specific Exchange Online mailboxes.
Action Setup
OData filters
Information on the filter input formatting can be found here.
Keep in mind that not specifying a folder as an input will result in the query affecting all possible folders. Example: If we want to ingest only unread emails, and we don't set the input "folder", we will ingest all unread emails from all folders, including "Deleted Items", "Junk", etc.
Well Known Folders
Well known folders can be used instead of Folder IDs for email actions. All well known folder names can be found here.
Sites Get Site
All the Sites actions require the site ID to be executed. The site ID can be obtained using the action Sites Get Site, in order to run the action the site_hostname and site_name are needed. This two values can be found in a site URL:
https://{site_hostname}.sharepoint.com/sites/{site_name}For example if our site URL is https://swimlaneintegrations.sharepoint.com/sites/IntegrationsSite we should use:
- site_hostname: swimlaneintegrations
- site_name: IntegrationsSite
After the action execution you can find the Site ID on the ID output field.
Sites Create List
In order to create a list with its columns, use the input Columns. You can find all the possible values with its configuration on the following table.
Property name | Type | Description |
|---|---|---|
boolean | This column stores boolean values. | |
calculated | This column's data is calculated based on other columns. | |
choice | This column stores data from a list of choices. | |
currency | This column stores currency values. | |
dateTime | This column stores DateTime values. | |
geolocation | This column stores a geolocation. | |
lookup | This column's data is looked up from another source in the site. | |
number | This column stores number values. | |
personOrGroup | This column stores Person or Group values. | |
text | This column stores text values. | |
validation | This column stores validation formula and message for the column. | |
hyperlinkOrPicture | This column stores hyperlink or picture values. | |
term | This column stores taxonomy terms. | |
thumbnail | This column stores thumbnail values. | |
contentApprovalStatus | This column stores content approval status. |
For a complete version of this table please see the official column definition table.
Create List Column
Refer to the above table to get the Type properties and Column type input. The Type properties are documented within the links in the Type column.
Get list items
In order to use the filter input please refer to the OData filtersο»Ώ section.
The column used to filter the output must be indexed, see the Microsoft documentation to add an index to a list.
Limitations
When using $filter and $orderby in the same query to get messages, make sure to specify properties in the following ways:
- Properties that appear in $orderby must also appear in $filter.
- Properties that appear in $orderby are in the same order as in $filter.
- Properties that are present in $orderby appear in $filter before any properties that aren't.
Failing to do this results in the following error:
- Error code: InefficientFilter
- Error message: The restriction or sort order is too complex for this operation.
The Assign/Remove User License requires either the disabled plans and accompanying SKU IDs to assign licenses or the SKU ID of the license you want to remove.
The Get Security Alert has additional information it can return. There are a large number of fields that don't relate to many alerts, so they are not mapped; you can add them if desired.
Notes
- oauthlib Legacy Application client, this is sort of a hack to bypass manual login (typically required)
Configurations
Microsoft Graph API Asset - Tenant ID
Authenticates using Client Credentials and Tenant ID
Configuration Parameters
Parameter | Description | Type | Required |
|---|---|---|---|
url | A URL to the target host. | string | Required |
tenant_id | The Tenant ID. | string | Required |
client_ID | The client ID | string | Required |
client_Secret | The client secret. | string | Required |
scope | List of permission scopes for this action. | array | Required |
verify_ssl | Verify SSL certificate | boolean | Optional |
http_proxy | A proxy to route requests through. | string | Optional |
Password Grant (Delegated Authentication)
Authenticates on behalf of a user using oauth 2.0 credentials
Configuration Parameters
Parameter | Description | Type | Required |
|---|---|---|---|
url | A URL to the target host. | string | Required |
login_url | ο»Ώ | string | Optional |
tenant_id | ο»Ώ | string | Required |
oauth_un | The username for authentication | string | Required |
oauth_pwd | The password for authentication | string | Required |
oauth_cl_id | The client ID | string | Required |
oauth_cl_secret | The client secret. | string | Required |
scope | Permission scopes for this action. | array | Optional |
verify_ssl | Verify SSL certificate | boolean | Optional |
http_proxy | A proxy to route requests through. | string | Optional |
Oauth 2.0 Client Credentials
Authenticates using oauth 2.0 client credentials
Configuration Parameters
Parameter | Description | Type | Required |
|---|---|---|---|
url | A URL to the target host. | string | Required |
token_url | Must start with https://login.microsoftonline.com/ and then continue with the tenant_id, and then be prepended with /oauth2/v2.0/token | string | Required |
client_id | The client ID | string | Required |
client_secret | The client secret. | string | Required |
scope | List of permission scopes for this action. | array | Required |
verify_ssl | Verify SSL certificate | boolean | Optional |
http_proxy | A proxy to route requests through. | string | Optional |
MS Graph OpenID Connect Refresh Token Grant
Authenticates using refresh token.
Configuration Parameters
Parameter | Description | Type | Required |
|---|---|---|---|
url | A URL to the target host. | string | Required |
cl_id | The client ID. | string | Required |
cl_secret | The client secret. | string | Required |
refresh_token | Refresh Token. | string | Optional |
verify_ssl | Verify SSL certificate | boolean | Optional |
http_proxy | A proxy to route requests through. | string | Optional |
Actions
Add Members
Adds a new member to a group using the 'group-id' and member's '@odata.id' in Microsoft Graph API.
Endpoint
- URL: /v1.0/groups/{{group-id}}/members/$ref
- Method: POST
Input
Argument Name | Type | Required | Description |
|---|---|---|---|
path_parameters.group-id | string | Required | The ID of the group to which the member will be added. |
@odata.id | string | Optional | The ID of the directory object to add as a member. |
Input Example
{"json_body":{"@odata.id":"https://graph.microsoft.com/v1.0/directoryObjects/{id}"},"path_parameters":{"group-id":"f0b2d6f5-097d-4177-91af-a24e530b53cc"}}
Output
Parameter | Type | Description |
|---|---|---|
status_code | number | HTTP status code of the response |
reason | string | Response reason phrase |
Output Example
{}
Create RejectedSender
Add a user or group to the rejected sender list in Microsoft Graph API using their unique ID.
Endpoint
- URL: /v1.0/groups/{{id}}/rejectedSenders/$ref
- Method: POST
Input
Argument Name | Type | Required | Description |
|---|---|---|---|
path_parameters.id | string | Required | The unique identifier for the group. |
@odata.id | string | Optional | The ID of a user or group object. |
Input Example
{"json_body":{"@odata.id":"https://graph.microsoft.com/v1.0/users/[email protected]"},"path_parameters":{"id":"732227b1-1927-49d4-bba9-cc30e6baf602"}}
Output
Parameter | Type | Description |
|---|---|---|
status_code | number | HTTP status code of the response |
reason | string | Response reason phrase |
response_text | string | Output field: response_text |
Output Example
{"response_text":"string"}
Response Headers
Header | Description | Example |
|---|---|---|
Cache-Control | Directives for caching mechanisms | no-cache |
client-request-id | HTTP response header: client-request-id | b15e85c5-d517-4e9e-a99e-d32ec5057dd7 |
Content-Encoding | HTTP response header: Content-Encoding | gzip |
Content-Type | The media type of the resource | application/json |
Date | The date and time at which the message was originated | Thu, 01 Jan 2024 00:00:00 GMT |
OData-Version | HTTP response header: OData-Version | 4.0 |
request-id | HTTP response header: request-id | b15e85c5-d517-4e9e-a99e-d32ec5057dd7 |
Strict-Transport-Security | HTTP response header: Strict-Transport-Security | max-age=31536000 |
Transfer-Encoding | HTTP response header: Transfer-Encoding | chunked |
Vary | HTTP response header: Vary | Accept-Encoding |
x-ms-ags-diagnostic | HTTP response header: x-ms-ags-diagnostic | {"ServerInfo":{"DataCenter":"Central India","Slice":"E","Ring":"3","ScaleUnit":"002","RoleInstance":"PN2PEPF00000273"}} |
x-ms-resource-unit | HTTP response header: x-ms-resource-unit | 2 |