11

I'm having a bit of trouble connecting to a private repo in order to get the certs and profiles. Here is some of the code that is running in a fastlane lane within the circle-ci job/workflow. I would imagine this would be possible because of here

username = ENV['USERNAME']
personal_github_access_token = ENV["PERSONAL_GITHUB_ACCESS_TOKEN"]
authorization_token_str = "#{username}:#{personal_github_access_token}"
basic_authorization_token = Base64.encode64(authorization_token_str)

match(
  git_basic_authorization:basic_authorization_token,
  type: "development",
  app_identifier: app_identifiers(),
  readonly: true
)

Error

[12:08:10]: Cloning remote git repo... [12:08:10]: If cloning the repo takes too long, you can use the clone_branch_directly option in match. Cloning into '/var/folders/1b/gl7yt7ds26vcyr1pkgld6l040000gn/T/d20191030-1122-178s7ae'... ERROR: Repository not found. fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists. [12:08:10]: Exit status: 128 [12:08:10]: Error cloning certificates repo, please make sure you have read access to the repository you want to use [12:08:10]: Run the following command manually to make sure you're properly authenticated:

Thanks for your comments and answers. :)

sitting-duck
  • 961
  • 1
  • 10
  • 22
Lamour
  • 3,002
  • 2
  • 16
  • 28

3 Answers3

10

This worked for me after the github changed started forcing me to use the github personal access token. I am pushing my code to testflight for beta testing

git_url("https://github.com/{github_username}/git_repo_name.git")
match(
  git_basic_authorization: Base64.strict_encode64("github_username:github_personal_token"),
  type: "appstore"
)
Jose
  • 1,959
  • 20
  • 21
  • 1
    Thank you for giving a clear answer. Everyone seems to assume that everyone knows how the git basic auth is created. – Xaxxus Dec 10 '21 at 20:04
  • Yeah, I feel the same way most times if people gave a little more context along with the answer it would help a lot more people and save a lot of time for others. – Jose Dec 12 '21 at 17:48
9

If you are using an OAuth token, make sure you are using git over https and not ssh.

Look in your Matchfile, it should be git_url("https://github.com/<user>/<repo>.git") and not git_url("git@github.com:<user>/<repo>.git")

If you need to use it over ssh, you need to configure a ssh key.

Juan
  • 147
  • 3
  • 6
  • 1
    I really wish their doc would make that a bit clearer, it may be obvious to some but not to everyone. Thanks for this answer :) – Eman Jan 06 '23 at 17:05
3

I have same problem and this works for me: Base64.strict_encode64

Found solution from here: https://github.com/fastlane/fastlane/issues/15682

axunic
  • 2,256
  • 18
  • 18
  • 1
    What do you mean by `Base64.strict_encode64`? Could you detail the steps you took to resolve the error? – NiFi Jun 08 '20 at 15:49
  • Sorry I can't give you detail steps because it may out context of this thread. It is an undocumented function provided by fastlane. if you want to use Fastlane Match, you have to provide `git_basic_authorization` token. To obtain that token, you have to provide `username` and `personal token` then encode them using `Base64.strict_encode64`. see link above for more info. – axunic Jun 09 '20 at 06:26
  • Thanks for your answer. There's really no more info behind that link at the moment. For future readers, what you need for that key is your GitHub username and pw or a personal access token (if 2FA is activated), and get a Base64 encoded value, with e.g. javascript `btoa('UNAME:PWorPAT')`. The `could not read Username` error appears if the encoded value isn't correct, i.e. `match` cannot authenticate https://github.com/fastlane/fastlane/issues/15682#issuecomment-573243571. – NiFi Jun 09 '20 at 06:43