Skip to content

Commit 763cb4b

Browse files
updates
1 parent e269eee commit 763cb4b

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

Modules/CIPPCore/Public/Get-CIPPAuthentication.ps1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@ function Get-CIPPAuthentication {
2222
#Get list of tenants that have 'directTenant' set to true
2323
$tenants = Get-Tenants -IncludeErrors | Where-Object -Property delegatedPrivilegeStatus -EQ 'directTenant'
2424
if ($tenants) {
25-
Write-Host "Found $($tenants.Count) tenants with directTenant set to true"
2625
$tenants | ForEach-Object {
2726
$secretname = $_.customerId -replace '-', '_'
2827
if ($secret.$secretname) {
2928
$name = $_.customerId
30-
Write-Host "Setting $name to $($secret.$secretname)"
31-
3229
Set-Item -Path env:$name -Value $secret.$secretname -Force
3330
}
3431
}

Modules/CIPPCore/Public/GraphHelper/Get-GraphToken.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ function Get-GraphToken($tenantid, $scope, $AsApp, $AppID, $AppSecret, $refreshT
77
if (!$env:SetFromProfile) { $CIPPAuth = Get-CIPPAuthentication; Write-Host 'Could not get Refreshtoken from environment variable. Reloading token.' }
88
#If the $env:<$tenantid> is set, use that instead of the refreshtoken for all tenants.
99
$refreshToken = $env:RefreshToken
10+
if (!$tenantid) { $tenantid = $env:TenantID }
1011
$ClientType = Get-Tenants -IncludeErrors -TenantFilter $tenantid
1112
if ($clientType.delegatedPrivilegeStatus -eq 'directTenant') {
13+
Write-Host "Using direct tenant refresh token for $($clientType.customerId)"
1214
$ClientRefreshToken = Get-Item -Path "env:\$($clientType.customerId)" -ErrorAction SilentlyContinue
1315
$refreshToken = $ClientRefreshToken.Value
1416
}
@@ -47,7 +49,6 @@ function Get-GraphToken($tenantid, $scope, $AsApp, $AppID, $AppSecret, $refreshT
4749
}
4850
}
4951

50-
if (!$tenantid) { $tenantid = $env:TenantID }
5152

5253
$TokenKey = '{0}-{1}-{2}' -f $tenantid, $scope, $asApp
5354

0 commit comments

Comments
 (0)