-
Notifications
You must be signed in to change notification settings - Fork 286
use_github does not push with https protocol and GITHUB_PAT #320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Is this different from the push problem with git2r from #300? |
When this function was initially created, back inside devtools, the Then here, its default was changed to But I don't see any arrangement made to fetch the GitHub PAT for git2r's use. gh will retrieve it automatically, yes, but that isn't going to help us in A PR to fix this would be welcome @cderv.
This is how people with 2FA turned on can still interact with GitHub over https. This is a deliberate choice. I push this way at this point because I know I have a PAT, since we needed to create a repo. |
Thanks for the clarification. I better understand the choices and what is going on. I understand the usethis/R/infrastructure-git.R Lines 111 to 115 in d5d20b1
I see two solutions using GITHUB_PAT :
I will PR something based on the second one, unless we could consider relying only on environment variable and you find the first one better. I'll do that quickly, don't worry. @batpigandme Yes this is a bit different. I mange to push when using https and the correct way to pass credential. Here, this is just a small issue of checking |
We obviously never circled back to this, even though git2r is now well past v0.11.0! In theory, we could use I have already brought a copy of
Here's the reference for what we're doing with the PAT and HTTPS: https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ If you make a PR, please include any manual tests you run. That would be a great start on #322, even if you don't finish it off, i.e. even if you just look at HTTPS scenarios. |
OK I see what to do. Thanks. TODO:
I'll do that this week. |
I tried to create a 📦 with
usethis
calling at some pointuse_github
.First my setup is:
.Renviron
gh::gh_whoami
.Howerver, when using https protocol,
use_github
does not manage to push to the created repo because of a mishandling of credential with git2r.Here how to reproduce the issue
the last step failed. The repository was created but use_github was not able to push to the repository. It seems it can’t deal with current git2r credential.
usethis/R/github.R
Lines 142 to 147 in 7d1c255
The credentials used are built with
cred <- git2r::cred_user_pass("EMAIL", auth_token)
.However, here
auth_token = NULL
by default andgit2r
does not know how to handle that.auth_token = NULL
by default indicates in the documentation that it should use the github PAT.I am really not sure to understand why the use of
cred_user_pass
with"EMAIL"
as username and anauth_token
as password. I will try to investigate further the reason of this choice, but if you have an explanation, please tell me.As it seems strange to me I tried another way.
First,
git2r
as specific credential object for token authentification, that by default get theGITHUB_PAT
environment variable. Using this works.There is also a way to use user/pass auth with the token using the username (or organization) and token as password.
A the end, do you think the choice in
use_github
is correct ? Should it be change to another credential object ? What are you thinking about all this ?I am wiling to help with a PR when ready. Thanks.
The text was updated successfully, but these errors were encountered: