usethis icon indicating copy to clipboard operation
usethis copied to clipboard

Some HTTP 403 errors offer context

Open aronatkins opened this issue 6 months ago • 0 comments

Using usethis 2.2.2, I struggled to understand why a refreshed GitHub token was not usable. Even after the token-update dance, I was still seeing errors like the following from usethis::use_release_issue():

Error: Unable to get GitHub info for these remotes: 'origin'
Are we offline? Is GitHub down? Has the repo been deleted?
Otherwise, you probably need to configure a personal access token (PAT) for 'github.com'
See `?gh_token_help` for advice

The feedback from usethis::git_sitrep() was similar:

• Desc = 'origin' is a GitHub repo and 'upstream' is either not configured or is not a GitHub repo.
  
  We may be offline or you may need to configure a GitHub personal access
  token. `gh_token_help()` can help with that.
  
  Read more about what this GitHub remote configurations means at:
  'https://happygitwithr.com/common-remote-setups.html'

I did not uncover any actionable feedback until digging into the lower-level calls made by usethis. Directly calling gh::gh() gave me:

Error in `gh::gh()`:
! GitHub API error (403): Resource protected by organization SAML enforcement. You must
  grant your Personal Access token access to this organization.
ℹ Read more at
  <https://docs.github.com/articles/authenticating-to-a-github-organization-with-saml-single-sign-on/>
Run `rlang::last_trace()` to see where the error occurred.

This was enough of a reminder - our SSO needs tokens to be authorized (a separate step after creation / refresh).

Is it possible for context about the original error to be provided to some of the higher-level calls?

aronatkins avatar Dec 13 '23 14:12 aronatkins