I'm writing an install script that's supposed to download a private repository from GitHub:
if Pat <> '' then
begin
Pat := Pat + '@'
end;
Url := Format('https://%sgithub.com/<MY_REPO>/%s/archive/main.zip', [Pat, RepoName]);
try
DownloadTemporaryFile(Url, 'main.zip', '', @OnDownloadProgress);
except
MsgBox('Failed to download the files from the GitHub repository.', mbError, MB_OK);
Abort();
end;
For a public repository, I can set Pat
to an empty string and this works without issue. However, for private repositories, I get a 404 response code. I've tried using a personal access token, and I've tried doing username:token
as well. Furthermore, I have verified that the organization name and repository name match and, when trying the URL from a browser, I can download the file. I also have MFA enabled on my account. How can I make this work?
This script is part of an installer where the user enters their PAT, which allows them to download and install the code in the repository. Only people with a valid PAT can access the code.
For PAT, see Clone A Private Repository (Github).