|
1 | 1 | [CmdletBinding()] |
2 | 2 | Param ( |
3 | | - [Parameter(Mandatory=$False)] |
4 | | - [array] $ArtifactList, |
5 | 3 | [Parameter(Mandatory=$True)] |
6 | | - [string] $ArtifactPath, |
| 4 | + [array] $ArtifactList, |
7 | 5 | [Parameter(Mandatory=$False)] |
8 | | - [string] $APIKey, |
| 6 | + [string] $ArtifactPath, |
9 | 7 | [string] $SourceBranch, |
10 | 8 | [string] $DefaultBranch, |
11 | 9 | [string] $RepoName, |
@@ -97,25 +95,17 @@ function Upload-SourceArtifact($filePath, $apiLabel, $releaseStatus, $packageVer |
97 | 95 |
|
98 | 96 | $uri = "${APIViewUri}/upload" |
99 | 97 |
|
100 | | - # Try Bearer token first, fall back to API key |
| 98 | + # Get Bearer token for authentication |
101 | 99 | $bearerToken = Get-ApiViewBearerToken |
102 | | - if ($bearerToken) { |
103 | | - $headers = @{ |
104 | | - "Authorization" = "Bearer $bearerToken"; |
105 | | - "content-type" = "multipart/form-data" |
106 | | - } |
107 | | - } |
108 | | - elseif ($APIKey) { |
109 | | - Write-Warning "##[warning]Bearer token acquisition failed - falling back to API key." |
110 | | - $headers = @{ |
111 | | - "ApiKey" = $APIKey; |
112 | | - "content-type" = "multipart/form-data" |
113 | | - } |
114 | | - } |
115 | | - else { |
116 | | - Write-Error "No authentication available. Either configure AzureCLI@2 task or provide APIKey." |
| 100 | + if (-not $bearerToken) { |
| 101 | + Write-Error "Failed to acquire Bearer token for APIView authentication." |
117 | 102 | return 401 |
118 | 103 | } |
| 104 | + |
| 105 | + $headers = @{ |
| 106 | + "Authorization" = "Bearer $bearerToken"; |
| 107 | + "content-type" = "multipart/form-data" |
| 108 | + } |
119 | 109 |
|
120 | 110 | try |
121 | 111 | { |
@@ -156,23 +146,16 @@ function Upload-ReviewTokenFile($packageName, $apiLabel, $releaseStatus, $review |
156 | 146 |
|
157 | 147 | Write-Host "Request to APIView: $uri" |
158 | 148 |
|
159 | | - # Try Bearer token first, fall back to API key |
| 149 | + # Get Bearer token for authentication |
160 | 150 | $bearerToken = Get-ApiViewBearerToken |
161 | | - if ($bearerToken) { |
162 | | - $headers = @{ |
163 | | - "Authorization" = "Bearer $bearerToken" |
164 | | - } |
165 | | - } |
166 | | - elseif ($APIKey) { |
167 | | - Write-Warning "##[warning]Bearer token acquisition failed - falling back to API key. Please migrate to using AzureCLI@2 task with service connection." |
168 | | - $headers = @{ |
169 | | - "ApiKey" = $APIKey |
170 | | - } |
171 | | - } |
172 | | - else { |
173 | | - Write-Error "No authentication available. Either configure AzureCLI@2 task or provide APIKey." |
| 151 | + if (-not $bearerToken) { |
| 152 | + Write-Error "Failed to acquire Bearer token for APIView authentication." |
174 | 153 | return 401 |
175 | 154 | } |
| 155 | + |
| 156 | + $headers = @{ |
| 157 | + "Authorization" = "Bearer $bearerToken" |
| 158 | + } |
176 | 159 |
|
177 | 160 | try |
178 | 161 | { |
|
0 commit comments