Skip to content

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

Closed

Description

@zkamvar

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)

Activity

  1. added
    gitgit, GitHub, and CI in general
    on Apr 15, 2021
  2. jennybc commented on Apr 15, 2021

    @jennybc
    Member

    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.

  3. added this to the milestone on Sep 28, 2021
  4. DataStrategist commented on Jun 23, 2023

    @DataStrategist

    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.

  5. added a commit that references this issue on Oct 21, 2024
    1824405
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    gitgit, GitHub, and CI in general

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions