Microsoft Graph API
Microsoft Graph API Pack.#
This Integration is part of theUse the Microsoft Graph API integration to interact with Microsoft APIs that do not have dedicated integrations in Cortex XSOAR, for example, Mail Single-User, etc.
Note: In this documentation, we will use the Application resource type as an example.
#
AuthorizationIn order to use the integration, there are 2 application authentication methods available.
Note: Depending on the authentication method that you use, the integration parameters might change.
#
Cortex XSOAR Azure appIn this method, the device authorization grant flow is used.
To configure the integration:
The Application ID integration parameter should be set to
8922dd2d-7539-4711-b839-374f86083959
(the Cortex XSOAR Azure app ID).The Scope integration parameter should be set according to the requested OAuth2 permissions types to grant access to in Microsoft identity platform, for more details see the Microsoft documentation. For example, if we wish to use the List applications API, we need at least the
Application.Read.All
scope.The Application Secret and the Tenant ID integration parameters should be left blank.
Run the msgraph-api-auth-start command - you will be prompted to open the page https://microsoft.com/devicelogin and enter the generated code.
Run the msgraph-api-auth-complete command
Run the msgraph-api-test command to ensure connectivity to Microsoft.
#
Self Deployed Azure appFor more information, refer to the following article.
#
Configure the Azure app- Register the app.
- Add the requested API permissions according to the APIs you wish to use. For example, according to the Create application API documentation in order to create applications we need the Application.ReadWrite.All application permission.
- Grant admin consent for the chosen permissions.
Note: The integration stores in cache the API access token based on the permissions it is first run with, so if the permissions are modified, it is recommended to create a new instance of the integration.
#
Configure Microsoft Graph API on Cortex XSOARNavigate to Settings > Integrations > Servers & Services.
Search for Microsoft Graph API.
Click Add instance to create and configure a new integration instance.
Parameter Description Required Azure Cloud See option table below. False Application ID False Application Secret (Required for using Self Deployed Azure app) False Tenant ID (Required for using Self Deployed Azure app) False Application redirect URI (for Self Deployed - Authorization Code Flow) False Authorization code (for Self Deployed - Authorization Code Flow) False Certificate Thumbprint False Private Key False Certificate Thumbprint Used for certificate authentication. As appears in the "Certificates & secrets" page of the app. False Private Key Used for certificate authentication. The private key of the registered certificate. False Use a self-deployed Azure Application Select this checkbox if you are using a self-deployed Azure application. False Use Azure Managed Identities Relevant only if the integration is running on Azure VM. If selected, authenticates based on the value provided for the Azure Managed Identities Client ID field. If no value is provided for the Azure Managed Identities Client ID field, authenticates based on the System Assigned Managed Identity. For additional information, see the Help tab. False Azure Managed Identities Client ID The Managed Identities client ID for authentication - relevant only if the integration is running on Azure VM. False Azure AD endpoint Azure AD endpoint associated with a national cloud. See note below. False Scope (Required for using Cortex XSOAR Azure app) A space-separated list of scopes that you want to consent to. False Trust any certificate (not secure) False Use system proxy settings False Azure cloud options
Azure Cloud Description Worldwide The publicly accessible Azure Cloud US GCC Azure cloud for the USA Government Cloud Community (GCC) US GCC-High Azure cloud for the USA Government Cloud Community High (GCC-High) DoD Azure cloud for the USA Department of Defense (DoD) Germany Azure cloud for the German Government China Azure cloud for the Chinese Government Custom Custom endpoint configuration to the Azure cloud. See note below. - Note: In most cases, setting Azure cloud is preferred to setting Azure AD endpoint. Only use it in cases where a custom URL is required for accessing a national cloud.
Click Test to validate the URLs, token, and connection.
#
CommandsYou can execute these commands from the Cortex XSOAR CLI, as part of an automation, or in a playbook. After you successfully execute a command, a DBot message appears in the War Room with the command details.
#
msgraph-api-auth-startRun this command to start the authorization process and follow the instructions in the command results.
#
msgraph-api-auth-completeRun this command to complete the authorization process. Should be used after running the msgraph-api-auth-start command.
#
msgraph-api-testTests connectivity to Microsoft.
#
msgraph-api-requestRun a Microsoft Graph API query.
#
Base Commandmsgraph-api
#
InputArgument Name | Description | Required |
---|---|---|
resource | The resource in Microsoft Graph to refer. | Required |
http_method | The HTTP method used for the request to Microsoft Graph. Possible values are: "GET", "POST", "DELETE", "PUT", or "PATCH". Default is "GET". | Optional |
api_version | The version of the Microsoft Graph API to use. Possible values are: "v1.0" or "beta". Default is "v1.0". | Optional |
request_body | The request body (required for POST queries). | Optional |
odata | OData system query options, e.g. $filter=startswith(givenName, 'J'). For more details see https://docs.microsoft.com/en-us/graph/query-parameters. It is recommended to use the $top query option to limit the result. | Optional |
populate_context | If "true", will populate the API response to the context data. Default is "true". | Optional |
#
Context OutputThe context data output depends on the resource executed. The populate_context argument sets whether to output to the context data, under the path MicrosoftGraph. For resources which return a large response, we recommend to narrow the results by using the odata argument or outputting to the context data using Extend Context.
#
msgraph-api-auth-resetRun this command if for some reason you need to rerun the authentication process.
#
Base Commandmsgraph-api-auth-reset
#
InputThere are no input arguments for this command.
#
Context OutputThere is no context output for this command.
#
msgraph-api-generate-login-urlGenerate the login URL used for Authorization code flow.
#
Base Commandmsgraph-api-generate-login-url
#
InputThere are no input arguments for this command.
#
Context OutputThere is no context output for this command.
#
Command Examplemsgraph-api-generate-login-url
#
Human Readable Output#
Authorization instructions
- Click on the login URL to sign in and grant Cortex XSOAR permissions for your Azure Service Management. You will be automatically redirected to a link with the following structure:
REDIRECT_URI?code=AUTH_CODE&session_state=SESSION_STATE
- Copy the
AUTH_CODE
(without thecode=
prefix, and thesession_state
parameter) and paste it in your instance configuration under the Authorization code parameter.
#
UsageLet's say we want to list all the applications.
We can see that according to the HTTP request:
- The HTTP method is GET
- The resource is /applications
So in order to list all the applications using the integration, we would run the command: !msgraph-api resource=/applications http_method=GET