r-lib / gitcreds

Query git credentials from R
https://gitcreds.r-lib.org/
Other
27 stars 10 forks source link

gitcreds_set() repeats forever and unable to set credentials #40

Closed brshallo closed 2 years ago

brshallo commented 2 years ago

I recently updated my PAT due to previously using an outdated format (had put off update for a bit).

I'm now having trouble connecting to github. When I do gitcreds_set() it shows everything as "dummy" values and selecting "2: Replace these credentials" is unable to progress and just keeps asking me the same thing:

> gitcreds::gitcreds_set()

-> Your current credentials for 'https://github.com':

  Logon failed, use ctrl+c to cancel basic credential prompt.: Logon failed, use ctrl+c to cancel basic credential prompt.
  protocol                                                   : dummy
  host                                                       : dummy
  username                                                   : dummy
  password                                                   : <-- hidden -->

-> What would you like to do? 

1: Keep these credentials
2: Replace these credentials
3: See the password / token

Selection: 2

-> Removing current credentials...

!! Found more matching credentials!

-> Your current credentials for 'https://github.com':

  Logon failed, use ctrl+c to cancel basic credential prompt.: Logon failed, use ctrl+c to cancel basic credential prompt.
  protocol                                                   : dummy
  host                                                       : dummy
  username                                                   : dummy
  password                                                   : <-- hidden -->

-> What would you like to do? 

1: Keep these credentials
2: Replace these credentials
3: See the password / token

Selection: 2

-> Removing current credentials...

!! Found more matching credentials!

-> Your current credentials for 'https://github.com':

  Logon failed, use ctrl+c to cancel basic credential prompt.: Logon failed, use ctrl+c to cancel basic credential prompt.
  protocol                                                   : dummy
  host                                                       : dummy
  username                                                   : dummy
  password                                                   : <-- hidden -->

-> What would you like to do? 

1: Keep these credentials
2: Replace these credentials
3: See the password / token

and so on...

> sessioninfo::session_info()
- Session info -----------------------------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.5.1 (2018-07-02)
 os       Windows 10 x64              
 system   x86_64, mingw32             
 ui       RStudio                     
 language (EN)                        
 collate  English_United States.1252  
 ctype    English_United States.1252  
 tz       America/Los_Angeles         
 date     2022-02-08                  

- Packages ---------------------------------------------------------------------------------------------------------------------------------------
 package     * version date       lib source        
 cli           3.1.0   2021-10-27 [1] CRAN (R 3.5.1)
 gitcreds      0.1.1   2020-12-04 [1] CRAN (R 3.5.1)
 sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 3.5.2)
 withr         2.4.3   2021-11-30 [1] CRAN (R 3.5.1)
 yaml          2.2.1   2020-02-01 [1] CRAN (R 3.5.3)

[1] C:/Users/BSHALLOW/Documents/R/win-library/3.5
[2] C:/Program Files/R/R-3.5.1/library
brshallo commented 2 years ago

What eventually worked was doing:

credentials::set_github_pat("my_pat")

And specifying my PAT when prompted for my password both in the github and then rstudio pop-up login screens.

gaborcsardi commented 2 years ago

What is your git version?

brshallo commented 2 years ago
$ git --version
git version 2.21.0.windows.1
gaborcsardi commented 2 years ago

Which credential help do you use? E.g. what is the output of

gitcreds::gitcreds_list_helpers()

Can you try listing all your credentials?

gitcreds::gitcreds_list()

(This needs the oskeyring R package.)

You can also start the 'Credential Manager' Windows app and check whether you indeed have many stale credentials here.

Finally, if you can, you can also update your git version, starting from git 2.29.0, git includes the manager-core credential helper, which is the usually the preferred one nowadays.

brshallo commented 2 years ago
> gitcreds::gitcreds_list_helpers()
[1] "manager"
> gitcreds::gitcreds_list()
[[1]]
<oskeyring_windows_item: generic>
 target_name: git:https://github.com
 persist: local_machine
 username: PersonalAccessToken
 credential_blob: <-- hidden -->

My Credential Manager has some git credentials for other git platforms (other than github, e.g. for dev.azure.com but just the one for github).

I'll look into updating my version of git soon.

(Feel free to close issue -- as mentioned had gotten working with {credentials}.)