git2r
git2r copied to clipboard
Can't push to GitHub via HTTPS without explicit credential
In general, I use SSH these days, but I just returned to an old project still set up with HTTPS. I took this chance to exercise git2r's https functionality a bit.
I'm trying to push to GitHub. I use 2FA on GitHub, so I need to send my PAT as the password. I have this PAT stored in the osxkeychain helper and system Git is finding and using that. That is, git push
works just fine in this repo.
However git2r is not using these cached credentials and, back when I used HTTPS exclusively, I believe that it did (?). But that also predated my use of 2FA.
If I explicitly tell git2r to send my PAT, I can push.
> push(r)
Error in push(r) :
Error in 'git2r_push': Unable to authenticate with supplied credentials
> push(r, credentials = cred_token())
Is this as it should be, i.e. I must explicitly say credentials = cred_token()
all the time? Or should git2r be able to use my cached token, as system Git is doing?
Possibly related to #289
Is there a way to go into some sort of verbose mode and see what "supplied credentials" git2r is sending?
I have the same question, but even I add the argument credentials = cred_token()
, I also get the error.
git2r::push(repo,credentials = cred_token())
Error in git2r::push(repo, credentials = cred_token()) :
Error in 'git2r_push': Unable to authenticate with supplied credentials
It would be helpful to have a way to configure credential method for a whole session without passing credential to each function.
Something like an option maybe.
options(git2r.credentials)
that we could set up in R profile and set to cred_token
for example.
I think it would be easy to implement as we could change change the credentials
argument to getOption("git2r.credentials
, NULL)`. I think that would not break the current credential.
Another option would be a cached git2r credential object that would be on disk and picked up when needed if it exists. Something like stored token in httr.
There are several ways - the aim is to have the ability to globally set credential object for git2r.
What do you think ?