Fastlane Match failed to connect using personal access token and username
Asked Answered
D

3

12

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. :)

Damascus answered 30/10, 2019 at 19:41 Comment(1)
do you solve it?Wunderlich
D
11

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("[email protected]:<user>/<repo>.git")

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

Drapery answered 28/10, 2020 at 18:13 Comment(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 :)Dur
R
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"
)
Ratcliffe answered 27/8, 2021 at 22:39 Comment(2)
Thank you for giving a clear answer. Everyone seems to assume that everyone knows how the git basic auth is created.Airport
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.Ratcliffe
W
3

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

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

Wunderlich answered 21/1, 2020 at 5:5 Comment(3)
What do you mean by Base64.strict_encode64? Could you detail the steps you took to resolve the error?Obscene
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.Wunderlich
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 github.com/fastlane/fastlane/issues/….Obscene

© 2022 - 2024 — McMap. All rights reserved.