#git #powershell
#git #powershell
Вопрос:
Пожалуйста, скажите мне, как я получаю скрипты, хранящиеся в репозитории Organistaion.
Я получаю Must authenticate to access this API
сообщение об ошибке:
$GithubCredentials = (Get-Credential -Message 'Please enter the Github User credentials')
$githubusername = $GithubCredentials.UserName
$githubpassword = $GithubCredentials.GetNetworkCredential().Password
$AuthString = "{0}:{1}" -f $githubusername,$githubpassword
$AuthBytes = [System.Text.Encoding]::Ascii.GetBytes($AuthString)
$global:BasicCreds = [Convert]::ToBase64String($AuthBytes)
$headers= @{
Authorization = 'Basic {0}' -f $BasicCreds;
"Accept" = "application/vnd.github.v3.raw";
};
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$GitHubUri = "https://alm-github.systems.test.com/api/v3/repos/test"
$data1 = Invoke-WebRequest -Uri $GitHubUri -Headers $headers -Method Get -Verbose
Комментарии:
1. Я не знаю, является ли это причиной вашей проблемы, но GitHub не рекомендует аутентификацию с помощью пользователя / пароля для API: docs.github.com/en/rest/overview/… Вам лучше сгенерировать токен и использовать его…
2. ОК. Это не проблема, потому что, похоже, вы используете свой экземпляр GitHub Enterprise…
3. теперь это работает с общедоступным репозиторием. после того, как я изменил репозиторий на частный, он не работает.