@@ -39,7 +39,7 @@ function Show-RepoList {
3939 }
4040
4141 LogGroup " Get repositories for organization [$Owner ]" {
42- $rawRepos = Get-GitHubRepository - Organization $Owner - AdditionalProperty @ (
42+ $rawRepos = Get-GitHubRepository - Owner $Owner - AdditionalProperty @ (
4343 ' description' ,
4444 ' default_branch' ,
4545 ' stargazers_count' ,
@@ -159,41 +159,6 @@ function Get-PropertyValue {
159159 return $Default
160160}
161161
162- function Get-GitHubAccessToken {
163- [OutputType ([string ])]
164- [CmdletBinding ()]
165- param ()
166-
167- $context = Get-GitHubContext
168- if ($null -eq $context ) {
169- return $null
170- }
171-
172- foreach ($propertyName in @ (' AccessToken' , ' Token' , ' token' )) {
173- $property = $context.PSObject.Properties [$propertyName ]
174- if ($null -eq $property ) {
175- continue
176- }
177-
178- $token = $property.Value
179- if ($token -is [securestring ]) {
180- $bstr = [Runtime.InteropServices.Marshal ]::SecureStringToBSTR($token )
181- try {
182- return [Runtime.InteropServices.Marshal ]::PtrToStringBSTR($bstr )
183- }
184- finally {
185- [Runtime.InteropServices.Marshal ]::ZeroFreeBSTR($bstr )
186- }
187- }
188-
189- if (-not [string ]::IsNullOrWhiteSpace([string ]$token )) {
190- return [string ]$token
191- }
192- }
193-
194- return $null
195- }
196-
197162function Invoke-GitHubApi {
198163 [OutputType ([object ])]
199164 [CmdletBinding ()]
@@ -202,18 +167,8 @@ function Invoke-GitHubApi {
202167 [string ] $Uri
203168 )
204169
205- $headers = @ {
206- Accept = ' application/vnd.github+json'
207- ' User-Agent' = ' PSModule-Docs-UpdateIndex'
208- }
209-
210- $accessToken = Get-GitHubAccessToken
211- if (-not [string ]::IsNullOrWhiteSpace($accessToken )) {
212- $headers.Authorization = " Bearer $accessToken "
213- }
214-
215170 try {
216- Invoke-RestMethod - Method Get - Uri $Uri - Headers $headers
171+ Invoke-GitHubAPI - Method GET - Uri $Uri - ErrorAction Stop
217172 }
218173 catch {
219174 $statusCode = $null
0 commit comments