0

I was trying to create a repo in gitHub via cURL. However whenever I am trying to create the repo the it gives me the login URL via a redirect and I'm not able to proceed anywhere from there. Doesn't give me an option to insert my credentials as well. I am using my access token to login. Not sure how do I proceed from here.

So below is the piece of cURL I'm trying:

curl -H "Authorization: token" -k https://enterprise.github.com/orgs/internal/repositories -d '{\"name\": \"testRepo\", \"description\": \"my test repo\", "\private\":\true\}'

And I always get the below response back:

<html><body>You are being <a href="https://enterprise.github.com/login?return_to=https%3A%2F%2Fenterprise.github.com%2Forgs%2Finternal%2Frepositories">redirected</a>.</body></html>

What I'm not able to figure out is how do I login from here and why do I have to do another login when I'm using access token to login? I have also tried using -L in the cURL, but that didn't helped either.

2
  • Is this on github.com or a GitHub Enterprise Server instance? Commented Oct 4, 2022 at 21:34
  • Its GitHUB Enterprise Server instance. Commented Oct 5, 2022 at 12:11

2 Answers 2

2

The problem is that you're accessing the web interface instead of the API. For security reasons, tokens are not allowed to access the web interface.

For a GitHub Enterprise Server instance, depending on how it's configured, you either need to access something under https://api.enterprise.github.com or under https://enterprise.github.com/api/v3, depending on how your instance is configured. That is, the URL should be either https://api.enterprise.github.com/orgs/internal/repositories or https://enterprise.github.com/api/v3/orgs/internal/repositories.

Sign up to request clarification or add additional context in comments.

1 Comment

Was there a solution
0

So I am able to get rid of the redirect issue by using the below cURL. However, now I am seeing "Cookies must be enabled to use GitHub." message as a response from the below cURL:

curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer access token" \
-k -L --post302 https://enterprise.github.com/orgs/internal/repositories \
-d '{\"name\": \"testRepo\", \"description\": \"my test repo\", "\private\":\true\}'

How to get rid of this Cookies must be enabled to use GitHub. error?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.