X Tutup
Skip to content

Commit b0b6701

Browse files
committed
Suggest to re-authenticate to fix "SAML enforcement" error
As far as I can put together, this error appears when someone has authenticated GitHub CLI with a PAT that isn't authorized to access a certain org. It can also happen if someone has authorized GitHub CLI using the legacy "GitHub CLI (dev)" OAuth app instead of our production OAuth app. Doing `gh auth refresh` will re-authenticate the user using our production "GitHub CLI" OAuth app which will not have problems accessing resources in different GitHub organizations.
1 parent 99cbfd3 commit b0b6701

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cmd/gh/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,15 @@ func mainRun() exitCode {
217217

218218
if strings.Contains(err.Error(), "Incorrect function") {
219219
fmt.Fprintln(stderr, "You appear to be running in MinTTY without pseudo terminal support.")
220-
fmt.Fprintln(stderr, "To learn about workarounds for this error, run: gh help mintty")
220+
fmt.Fprintln(stderr, "To learn about workarounds for this error, run: gh help mintty")
221221
return exitError
222222
}
223223

224224
var httpErr api.HTTPError
225225
if errors.As(err, &httpErr) && httpErr.StatusCode == 401 {
226-
fmt.Fprintln(stderr, "hint: try authenticating with `gh auth login`")
226+
fmt.Fprintln(stderr, "Try authenticating with: gh auth login")
227+
} else if strings.Contains(err.Error(), "Resource protected by organization SAML enforcement") {
228+
fmt.Fprintln(stderr, "Try re-authenticating with: gh auth refresh")
227229
}
228230

229231
return exitError

0 commit comments

Comments
 (0)
X Tutup