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

Default GitHub token is not valid for github.com when using GitHub Enterprise #196

Closed
gdw2 opened this issue Oct 11, 2023 · 5 comments · Fixed by #200
Closed

Default GitHub token is not valid for github.com when using GitHub Enterprise #196

gdw2 opened this issue Oct 11, 2023 · 5 comments · Fixed by #200
Labels
bug Something isn't working enterprise Affects GitHub Enterprise runners

Comments

@gdw2
Copy link

gdw2 commented Oct 11, 2023

Expected

If I don't explicitly specify a github token, I would expect it to try to access github 'anonymously' (subject to rate limiting).

Actual

(From the nix-shell-action action which leverages the work done by install-nix-action. )

error:
       … while fetching the input 'github:NixOS/nixpkgs/nixpkgs-unstable'

       error: unable to download 'https://api.github.com/repos/NixOS/nixpkgs/commits/nixpkgs-unstable': HTTP error 401

       response body:

       {
         "message": "Bad credentials",
         "documentation_url": "https://docs.github.com/rest"
       }

Analysis

I'd like to be able to use install-nix-action without a github token, but I don't think it's possible to withhold the $GITHUB_TOKEN from the script. I tried passing GITHUB_TOKEN as an empty string, but I think github overrides it with my actual token.

Since I'm using Github Enterprise, my token isn't valid for github.com, so I get the "Bad credentials" error above.

My solution was to fork this repo, and comment out these lines and then it works fine for me.

@sandydoo
Copy link
Member

sandydoo commented Nov 2, 2023

We could check whether $GITHUB_SERVER_URL or {{ github.server_url }} is set to https://github.com. If it's not, then we don't use the default token. @gdw2 , would you be able to test this out for us if we roll out a fix?

@sandydoo sandydoo added bug Something isn't working enterprise Affects GitHub Enterprise runners labels Nov 2, 2023
@sandydoo sandydoo changed the title Can't use with github enterprise Default GitHub token is not valid for github.com when using GitHub Enterprise Nov 2, 2023
@gdw2
Copy link
Author

gdw2 commented Nov 2, 2023 via email

sandydoo added a commit that referenced this issue Nov 3, 2023
The token on Enterprise instances is not valid for github.com.

Resolves #196.
sandydoo added a commit that referenced this issue Nov 3, 2023
The token on Enterprise instances is not valid for github.com.

Resolves #196.
@sandydoo
Copy link
Member

sandydoo commented Nov 3, 2023

@gdw2, could you please test this branch when you have the chance?

- uses: cachix/install-nix-action@fix/196

@domenkozar
Copy link
Member

@gdw2 ping :)

@gdw2
Copy link
Author

gdw2 commented Nov 27, 2023

I think it worked. I'm getting the following message in a latter stage (using the nix-shell-action action), which means I may have to use a token after all, but that's my problem:

{"message":"API rate limit exceeded for XX.XX.XX.XXX. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)

I'd go ahead and merge this. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enterprise Affects GitHub Enterprise runners
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants