Add browser auth for headless runs

This commit is contained in:
2026-04-08 16:09:30 +02:00
parent c803a00df7
commit 239e3ec16e
12 changed files with 222 additions and 19 deletions

View File

@@ -1313,6 +1313,7 @@ function Show-GraphExportForm
function Invoke-InitSilentBatchJob
{
$global:MSALToken = $null
$headlessAuthMode = ?? $global:HeadlessAuthMode "AppOnly"
if(-not $global:TenantId)
{
@@ -1320,12 +1321,15 @@ function Invoke-InitSilentBatchJob
return
}
if(-not $global:AzureAppId -or (-not $global:ClientSecret -and -not $global:ClientCert))
if(-not $global:AzureAppId -or ($headlessAuthMode -eq "AppOnly" -and (-not $global:ClientSecret -and -not $global:ClientCert)))
{
# Get login info for silent job from settings
$global:AzureAppId = Get-SettingValue "GraphAzureAppId" -TenantID $global:TenantId
$global:ClientSecret = Get-SettingValue "GraphAzureAppSecret" -TenantID $global:TenantId
$global:ClientCert = Get-SettingValue "GraphAzureAppCert" -TenantID $global:TenantId
if($headlessAuthMode -eq "AppOnly")
{
$global:ClientSecret = Get-SettingValue "GraphAzureAppSecret" -TenantID $global:TenantId
$global:ClientCert = Get-SettingValue "GraphAzureAppCert" -TenantID $global:TenantId
}
}
if(-not $global:AzureAppId)
@@ -1334,7 +1338,7 @@ function Invoke-InitSilentBatchJob
return
}
if(-not $global:ClientSecret -and -not $global:ClientCert)
if($headlessAuthMode -eq "AppOnly" -and -not $global:ClientSecret -and -not $global:ClientCert)
{
Write-Log "Secret or Certificate must be specified. Either specify Secret/Certificate in Settings or Command Line" 3
return