Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Convert live test clean-up to use WIF for open source api access
  • Loading branch information
weshaggard authored and azure-sdk committed May 16, 2024
commit 196eb3d698dd0b5940fd348a3b62441b1a4a3a04
10 changes: 6 additions & 4 deletions eng/common/scripts/Helpers/Metadata-Helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ function Generate-AadToken ($TenantId, $ClientId, $ClientSecret)
return $resp.access_token
}

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

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

try {
$opsAuthToken = Generate-AadToken -TenantId $TenantId -ClientId $ClientId -ClientSecret $ClientSecret
$Headers["Authorization"] = "Bearer $opsAuthToken"
if (!$Token) {
$Token = Generate-AadToken -TenantId $TenantId -ClientId $ClientId -ClientSecret $ClientSecret
}
$Headers["Authorization"] = "Bearer $Token"
Write-Host "Fetching all github alias links"
$resp = Invoke-RestMethod $OpensourceAPIBaseURI -Method 'GET' -Headers $Headers -MaximumRetryCount 3
} catch {
Expand Down