Forum Discussion
ImranAslam
Dec 04, 2023Copper Contributor
Microsoft Defender EndPoint API's Access Token in Azure DataFactory
Hi All,
I am trying to pull Defender EndPoint API data through Data Factory pipelines. I am able to generate token and tested in PostMan and Azure DataFactory and all working fine.
The only issue I am getting the generation of AcessToken. Currently I am have to use the below script in PowerShell to generate the Access Token:
# This script acquires the App Context Token and stores it in the variable $token for later use in the script.
# Paste your Tenant ID, App ID, and App Secret (App key) into the indicated quotes below.
$tenantId = '' ### Paste your tenant ID here
$appId = '' ### Paste your Application ID here
$appSecret = '' ### Paste your Application key here
$sourceAppIdUri = 'https://api.securitycenter.microsoft.com/.default'
$oAuthUri = "https://login.microsoftonline.com/$TenantId/oauth2/token"
$authBody = [Ordered] @{
scope = "$sourceAppIdUri"
client_id = "$appId"
client_secret = "$appSecret"
grant_type = 'client_credentials'
}
$authResponse = Invoke-RestMethod -Method Post -Uri $oAuthUri -Body $authBody -ErrorAction Stop
$token = $authResponse.access_token
$token
and then use in my Pipeline to get the data as per the API.
Is there any way I can generate access token directly in my ADF pipeline and pass to pipeline. Any idea or guidance's will be appreciated.
Many Thanks
Imran Aslam
No RepliesBe the first to reply