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

Document how to fix "Resource protected by organization SAML enforcement" #2661

Closed
hoxu opened this issue Dec 21, 2020 · 10 comments · Fixed by #4241
Closed

Document how to fix "Resource protected by organization SAML enforcement" #2661

hoxu opened this issue Dec 21, 2020 · 10 comments · Fixed by #4241
Labels
enhancement a request to improve CLI p2 Affects more than a few users but doesn't prevent core functions

Comments

@hoxu
Copy link

hoxu commented Dec 21, 2020

When an organization enables SAML enforcement, gh starts giving the following error:

$ gh pr create ...
GraphQL error: Resource protected by organization SAML enforcement. You must grant your OAuth token access to this organization.

This is confusing, because if you check your https://github.com/settings/tokens page, the gh token is not there, so it's not immediately obvious what the user should do.

What is required is re-authentication, but it would be a good idea to cover this in a FAQ entry:

$ gh auth login
? What account do you want to log into? GitHub.com
- Logging into github.com
? You're already logged into github.com as XXX. Do you want to re-authenticate? Yes

Or maybe just tell the user to run gh auth login when the command fails with that error.

@hoxu hoxu added the enhancement a request to improve CLI label Dec 21, 2020
@vilmibm vilmibm added the p2 Affects more than a few users but doesn't prevent core functions label Jan 28, 2021
@viliam-durina
Copy link

Thankfully google took me here so this issue already acts as a FAQ entry.

@leiflundberg
Copy link

Bumping this as it fixed my problem 👍🏼

@imonkia
Copy link

imonkia commented Jan 13, 2023

This was super helpful. Spent an unnecessary amount of time trying to "fix" this "issue". Thanks!

@AnkurAgarwal-ST
Copy link

Super helpful, fixed my issue immediately.

@rkaurSFDX
Copy link

Fixed my issue as well, thanks a ton!

@D99013682
Copy link

I have a service connection between Azure DevOps and GitHub for the pipelines to communicate with. It isn't possible to have the user re-authorize with a command. How do I fix the service connection to be re-authorized so when the pipeline is triggered it doesn't need this?

@ffisc
Copy link

ffisc commented Dec 20, 2023

Thanks for the solution.
@mislav I'm not sure why this issue is closed, since I just got the error and didn't get any suggestions of what to do.
In fact the behavior was misleading: I got a link to authorize in my browser, followed the authorization, but continued to get an error. Only gh auth login fixed it.

@zyrain
Copy link

zyrain commented Mar 14, 2024

This is not fixed. Re-open please.

@andyfeller
Copy link
Contributor

for posterity, I'm explicitly linking this back to #5054 where the original solution was reworked to give users direction to authorize the organization associated with the PAT within the web browser:

cli/cmd/gh/main.go

Lines 158 to 166 in 6f558c9

var httpErr api.HTTPError
if errors.As(err, &httpErr) && httpErr.StatusCode == 401 {
fmt.Fprintln(stderr, "Try authenticating with: gh auth login")
} else if u := factory.SSOURL(); u != "" {
// handles organization SAML enforcement error
fmt.Fprintf(stderr, "Authorize in your web browser: %s\n", u)
} else if msg := httpErr.ScopesSuggestion(); msg != "" {
fmt.Fprintln(stderr, msg)
}

@andyfeller
Copy link
Contributor

This is not fixed. Re-open please.

@zyrain : Please create a new issue including terminal commands, output, gh version, and any verbose / debug information so we can triage and prioritize! ❤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement a request to improve CLI p2 Affects more than a few users but doesn't prevent core functions
Projects
None yet
Development

Successfully merging a pull request may close this issue.