Justintime50 / github-archive

A powerful tool to concurrently clone, pull, or fork user and org repos and gists to create a GitHub archive.
MIT License
186 stars 48 forks source link

Fails to authenticate when token is used? #56

Closed 8465231 closed 1 year ago

8465231 commented 1 year ago

So was testing actually going live with the pull and while everything works great during the dry run, when I remove the dry run and try running the command for real I get errors.

Running github-archive -t my_token -c -u 0x0ece

Fails with

# Making API calls to GitHub for user repos...
# Cloning missing user repos...
The authenticity of host 'github.com (140.82.113.3)' can't be established.
ECDSA key fingerprint is SHA256:fghd98fgh09dfh7g09d7fgh098d7fg09hd
Are you sure you want to continue connecting (yes/no/[fingerprint])? ^CTraceback (most recent call last):

If I try running it with --https it works. If I use the -v dry run option it works with the token. I can confirm it was using my token as well since if I checked my rate limits with this command it would show that my token was used: https://docs.github.com/en/rest/rate-limit?apiVersion=2022-11-28

I still have 4800 calls remaining BTW, so should not be a rate limit issue.

I tried creating a brand new token on github with all permissions, both the new and classic token as well but the same error. Also tried both org and user and same error on both.

Any ideas?

Small side question, if put into pull mode, it will not download a repo that has not been cloned previously, is this by design?

Justintime50 commented 1 year ago

See the section of the README discussing adding your SSH key to the agent so you don't get prompted.

Yes, cloning and pulling are separate by design which allows for great flexibility. We don't want to assume that users want to clone the difference. For the workflow I think you're after, you'll want to include both clone and pull, it will skip cloning repos that already exist.

Let me know if that works for you

8465231 commented 1 year ago

The readme made it sound like you only needed the ssh key if you were dealing with private repos? I am only messing with public?

I did go ahead and add an ssh key to the system / github account but the error remains?

I generated the key following this: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

I added it with this https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account

I then ran the ssh-add command as well from the readme.

Justintime50 commented 1 year ago

So using a token (ssh) authenticates you with GitHub. They have a pretty low unauthenticated limit of something like 100 requests an hour? If you use the --https flag, it will not be authenticated. This means you cannot get private repos and you will be rate limited by GitHub.

If using the --token flag, you get access to private repos as well as won't get rate limited (unless you make an absurd number of API calls).

Now that you have setup ssh correctly, you'll need to add github to your known hosts (this issue you've reported is not one with this tool. Running something like ssh-keyscan github.com >> ~/.ssh/known_hosts should do the trick.

Let me know if that works.

8465231 commented 1 year ago

Now that you have setup ssh correctly, you'll need to add github to your known hosts (this issue you've reported is not one with this tool. Running something like ssh-keyscan github.com >> ~/.ssh/known_hosts should do the trick.

Perfect, that seems to of done the trick!

This is my first time using the API so still very much in the learning stages, I am not a coder, my job is just to backup the repos I am told to backup and make sure they are safe lol.

Thanks a ton for all the help, hopefully this is the last issue I run into!