aaronpeikert / repro

Easy Setup of a Reproducible Workflow
GNU General Public License v3.0
34 stars 7 forks source link

Error in validate_gh_pat(new_gh_pat(x)) : A GitHub PAT must consist of 40 hexadecimal digits #65

Open GlascherLab opened 3 years ago

GlascherLab commented 3 years ago

Hi Aaron,

I went through your preps for the workshop next week and got stuck at the check_github() stage. First, it said i did't have access to github. Then I read through the ssh-key help file and used my id_rsa.pub (retrieved in RStudio and made it available on GitHub. ssh -T git@github.com was successful. But when I then reran repro::check_github() I got the error message in the title.

Any ideas?

I should mentioned that I just transitioned to a new MBP with the silicon chip, but I run R/Rstudio in legacy mode with rosetta2 support for the x86 architecture. I copied my existing ssh-keys to the new computer and used those in RStudio / GitHub.

Could this be the issue and do I have to generate new ssh-keys? I wonder if new keys interfere for instance with my GPG keys save in my GPG Keychain (part of GPG tools for Mac) and with other services in out institute network that build on the existing public-private key encryption ...

Thanks, Jan

aaronpeikert commented 3 years ago

Hi Jan, great that you are preparing. check_github does basically three things, check for git, check for ssh connection to github (with ssh -T git@github.com) and check for GitHub pat/token:

repro::check_github
#> function(){
#>   if (!has_n_check(has_git, check_git)) {
#>     msg_rerun("check_github()")
#>     return(FALSE)
#>   } else if (!has_n_check(has_ssh, check_ssh)) {
#>     msg_rerun("check_github()")
#>     return(FALSE)
#>   } else if (!has_n_check(has_github_ssh, check_github_ssh)) {
#>     msg_rerun("check_github()")
#>     return(FALSE)
#>   } else if (!has_n_check(has_github_token, check_github_token)) {
#>     msg_rerun("check_github()")
#>     return(FALSE)
#>   } else {
#>     invisible(has_github(silent = FALSE))
#>   }
#> }
#> <bytecode: 0xfdb448>
#> <environment: namespace:repro>

Created on 2021-03-25 by the reprex package (v1.0.0)

It does seem to me that git + GitHub ssh is working, but you could verify with:

repro::check_git()
#> ✓ Git is installed, don't worry.
repro::check_github_ssh()
#> ✓ You have SSH access to GitHub, don't worry.

Created on 2021-03-25 by the reprex package (v1.0.0)

The GitHub pat/token is something different from ssh keys. The token gives you programmatic access to GitHub so that you, e.g. can create a new repo from within r. Try:

usethis::create_github_token()

if this still doesn't work, try:

usethis::gh_token_help()

If you still not getting anywhere, don't worry too much. You will still have fun at the workshop. Report back if you think I can help you further! See you soon Aaron

GlascherLab commented 3 years ago

Hi Aaron,

thank for the swift reply.

You were right: check_git() and check_git_ssh() work just fine.

create_github_token() give me this output:

Call gitcreds::gitcreds_set() to register this token in the local Git credential store It is also a great idea to store this token in any password-management software that you use ✓ Opening URL 'https://github.com/settings/tokens/new?scopes=repo,user,gist,workflow&description=R:GITHUB_PAT'

I checked out gitcreds_set(),but didn't want to change my GitHub credentials

I also registered a GitHub token under the above mentioned URL, but I am still getting the GitHub pat/token error, but if this is not material to the workshop, I think I'll just use what I have right now.

Thanks, Jan

aaronpeikert commented 3 years ago

Hi Jan, if you do not save the pat with gitcreds_set(), it will not work. Of course, you shouldn't do that if you are not comfortable with it. Still, I am wondering, what exactly do you mean by:

I checked out gitcreds_set() but didn't want to change my GitHub credentials

Not to change your mind, but to clarify. It doesn't change your username password or anything; it just gives your computer a way to log in to your GitHub account automatically. You yourself, as a user, are not affected (in the sense that you can still proceed with everything as you are used to).

GlascherLab commented 3 years ago

HI Aaron,

when I call gitcreds_set() it lists protocols-host-username-password (hidden) and I get 3 options on the command line: (1) keep these credentials, (2) replace these credentials, and (3) see password token. I assumed that (2) would replace my credentials, which I didn’t want to do, but maybe i misunderstood this altogether.

Thanks for any clarification, Jan

On Mar 25, 2021, at 12:16 PM, aaronpeikert @.***> wrote:

Hi Jan, if you do not save the pat with gitcreds_set(), it will not work. Of course, you shouldn't do that if you are not comfortable with it. Still, I am wondering, what exactly do you mean by:

I checked out gitcreds_set() but didn't want to change my GitHub credentials

Not to change your mind, but to clarify. It doesn't change your username password or anything; it just gives your computer a way to log in to your GitHub account automatically. You yourself, as a user, are not affected (in the sense that you can still proceed with everything as you are used to).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/aaronpeikert/repro/issues/65#issuecomment-806568046, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEFBBGXIE7IMZ54K66U7NM3TFMLR5ANCNFSM4ZZBYK7Q.

aaronpeikert commented 3 years ago

Indeed 2 would replace the existing credentials. Now I understand your hesitation. If you don't want to delete/replace these credentials, there is documentation for setting up multiple credentials for MacOs: https://gitcreds.r-lib.org/reference/gitcreds_get.html

Anyways, the token will only be needed for some automatisation with GitHub, mainly for users who have never used GitHub. Nothing fancy and nothing you can't do yourself manually.

GlascherLab commented 3 years ago

Excellent. Thanks for the tip. I’ll look into this.

See you next week, Jan

On Mar 25, 2021, at 1:12 PM, aaronpeikert @.***> wrote:

Indeed 2 would replace the existing credentials. Now I understand your hesitation. If you don't want to delete/replace these credentials, there is documentation for setting up multiple credentials for MacOs: https://gitcreds.r-lib.org/reference/gitcreds_get.html https://gitcreds.r-lib.org/reference/gitcreds_get.html Anyways, the token will only be needed for some automatisation with GitHub, mainly for users who have never used GitHub. Nothing fancy and nothing you can't do yourself manually.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/aaronpeikert/repro/issues/65#issuecomment-806623407, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEFBBGXUO5K5P5USIUWNZR3TFMSCPANCNFSM4ZZBYK7Q.

aaronpeikert commented 3 years ago

Hey Jan, I just talked with Tina Lonsdorf about her problems and it turns out she had the same problem as you did (and #66 ). I guess the most probable cause of your error is that you have used github via https before and supplied your username and password, which created the mysterious credentials. As this should be pretty common, I consider this a bug in repro and will look into it. I guess it is safe to overwrite these credentials. To clarify again, your ssh setup will not be altered. Overwriting the credentials is independent of ssh and will only affect GitHub.

GlascherLab commented 3 years ago

Hi Aaron,

indeed my GitHub account lists https as the connection protocol. As this is coming to a close in the fall anyways, will it make sense to swath to ssh as the GitHub protocol? And if yes, do you know how to do this?

Thanks, Jan

On Mar 25, 2021, at 5:34 PM, aaronpeikert @.***> wrote:

Hey Jan, I just talked with Tina Lonsdorf about her problems and it turns out she had the same problem as you did (and #66 https://github.com/aaronpeikert/repro/issues/66 ). I guess the most probable cause of your error is that you have used github via https before and supplied your username and password, which created the mysterious credentials. As this should be pretty common, I consider this a bug in repro and will look into it. I guess it is safe to overwrite these credentials. To clarify again, your ssh setup will not be altered. Overwriting the credentials is independent of ssh and will only affect GitHub.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/aaronpeikert/repro/issues/65#issuecomment-807057962, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEFBBGTHNZ3O6RIZFBPHXITTFNQYXANCNFSM4ZZBYK7Q.

aaronpeikert commented 3 years ago

Hi Jan, there are three methods:

I used to use ssh for years but switched over to HTTPS with token last years. To switch to https token, just gitcreds_set() + "(2) replace these credentials"

To switch to ssh, just follow: https://docs.github.com/en/github/using-git/changing-a-remotes-url

You have set up ssh successfully already :partying_face: !

You can also mix and match ssh + HTTPS.

My recommendation is to switch to HTTPS + token.

GlascherLab commented 3 years ago

Hi Aaron,

Thanks for the explanation and the tips. This really useful information.

Best, Jan

Sent from my iPhone

On 25. Mar 2021, at 19:37, aaronpeikert @.***> wrote:

 Hi Jan, there are three methods:

HTTPS with password and username, the main benefit is the easy setup (BUT) ssh keys, the main benefit is the stability HTTPS with token/pat, the main benefit is the API access I used to use ssh for years but switched over to HTTPS with token last years. To switch to https token, just gitcreds_set() + "(2) replace these credentials"

To switch to ssh, just follow: https://docs.github.com/en/github/using-git/changing-a-remotes-url

You have set up ssh successfully 🥳

You can also mix and match ssh + HTTPS.

My recommendation is to switch to HTTPS + token.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.