Skip to content
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

Should gh_token_help() report bad credentials (401)? #1413

Closed
zkamvar opened this issue Apr 7, 2021 · 2 comments
Closed

Should gh_token_help() report bad credentials (401)? #1413

zkamvar opened this issue Apr 7, 2021 · 2 comments
Labels
git git, GitHub, and CI in general

Comments

@zkamvar
Copy link
Contributor

zkamvar commented Apr 7, 2021

I know this is covered in git_sitrep(), but I'm wondering if gh_token_help() should report if a discovered token throws a 401 error.

For example, I have a token whose access I just revoked, but gh_token_help() does not report any errors:

usethis::gh_token_help()
#> ● GitHub host: 'https://github.com'
#> ● Host online: TRUE
#> ● Personal access token for 'https://github.com': '<discovered>'
#> ℹ Call `gh::gh_whoami()` to see info about your token, e.g. the associated user
#> ℹ To see or update the token, call `gitcreds::gitcreds_set()`
#> ✔ If those results are OK, you are good go to!
#> ℹ Read more in the 'Managing Git(Hub) Credentials' article:
#>   https://usethis.r-lib.org/articles/articles/git-credentials.html
gh::gh_whoami()
#> Error in gh_process_response(raw): 
#> GitHub API error (401): 
#> Message: Bad credentials
#> Read more at https://docs.github.com/rest

Created on 2021-04-07 by the reprex package (v2.0.0)

@jennybc jennybc added the git git, GitHub, and CI in general label Apr 15, 2021
@jennybc
Copy link
Member

jennybc commented Apr 15, 2021

Note to self: Just did some troubleshooting with Tareef, who had an invalid PAT in .Renviron and had set a good PAT via gitcreds. On RStudio Server and the aggravating failure was from remotes::install_github(). I.e. he couldn't install from GitHub because remotes was finding the bad PAT in the env var.

I need to recreate this situation and see what help git_sitrep() and gh_token() offers (or not). And also make sure Happy Git is sending people to these functions for troubleshooting.

@jennybc jennybc added this to the v2.1.0 milestone Sep 28, 2021
@jennybc jennybc closed this as completed in 1824405 Oct 2, 2021
@DataStrategist
Copy link

Just leaving a note here as a concise list to check in case nothing seems to be working:

The PAT could be saved in multiple places on a Windows computer. The following should be checked:

  • the .Renviron in the User's HOME. By default that's in "Documents"
  • Project specific .Renvirons, which would be in the root of project folders
  • The Windows Credential Manager. Find it by typing "Credential Manager" into the Windows search. Switch to "Windows Credential" and delete anything that says GitHub on it
  • The Windows Environment Variables. Make sure you check both the user and system locations.

I somehow managed to have random PATs saved in each one of these categories. Deleting everything let me follow normal instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
git git, GitHub, and CI in general
Projects
None yet
Development

No branches or pull requests

3 participants