Skip to content

Commit de7c112

Browse files
Convert live test clean-up to use WIF for open source api access (Azure#44090)
Co-authored-by: Wes Haggard <[email protected]>
1 parent 7d9a02e commit de7c112

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

eng/common/scripts/Helpers/Metadata-Helpers.ps1

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ function Generate-AadToken ($TenantId, $ClientId, $ClientSecret)
1717
return $resp.access_token
1818
}
1919

20-
function GetAllGithubUsers ([string]$TenantId, [string]$ClientId, [string]$ClientSecret)
20+
function GetAllGithubUsers ([string]$TenantId, [string]$ClientId, [string]$ClientSecret, [string]$Token)
2121
{
22-
# API documentation (out of date): https://github.com/microsoft/opensource-management-portal/blob/main/docs/api.md
22+
# API documentation: https://github.com/1ES-microsoft/opensource-management-portal/blob/trunk/docs/microsoft.api.md
2323
$OpensourceAPIBaseURI = "https://repos.opensource.microsoft.com/api/people/links"
2424

2525
$Headers = @{
@@ -28,8 +28,10 @@ function GetAllGithubUsers ([string]$TenantId, [string]$ClientId, [string]$Clien
2828
}
2929

3030
try {
31-
$opsAuthToken = Generate-AadToken -TenantId $TenantId -ClientId $ClientId -ClientSecret $ClientSecret
32-
$Headers["Authorization"] = "Bearer $opsAuthToken"
31+
if (!$Token) {
32+
$Token = Generate-AadToken -TenantId $TenantId -ClientId $ClientId -ClientSecret $ClientSecret
33+
}
34+
$Headers["Authorization"] = "Bearer $Token"
3335
Write-Host "Fetching all github alias links"
3436
$resp = Invoke-RestMethod $OpensourceAPIBaseURI -Method 'GET' -Headers $Headers -MaximumRetryCount 3
3537
} catch {

0 commit comments

Comments
 (0)