Authentication Steps for GitHub Enterprise


#1

I have an enterprise GitHub at https://github.subcompany.parentcompany.com.

I’ve sent it this request, with <my Personal Access Token with Repo Access> filled with an actual personal access token, to find the enterprise, non-private repos that currently have the topic “go” (which definitely exist).

curl -H "Content-Type: application/json" -H "Authorization: token <my Personal Access Token with Repo Access>“ -i -X -d “{ \”query\”: \”query { search(type: REPOSITORY, query:\"topic:go\”, first: 10) { edges { node { ... on Repository { name }}}}}\”}" https://github.subcompany.parentcompany.com/api/graphql

After much fiddling with the query and the header to ensure my token was recognised (well, the multiple I generated while trying to get “Good crendentials”), I ended up with this error:

{
  "message": "Bad credentials",
  "documentation_url": "https://developer.github.com/enterprise/2.12/v3"
}

Other Details: We haven’t yet used the API, so if the sysadmin (who is also having issues with accessing this) had to enable or disable something, it probably wasn’t configured as such. We do have a corporate firewall and essentially mandate SSH, but neither of those are issues for me personally when cloning, pulling, pushing, etc.

What am I missing or otherwise doing wrong?


#2

Hey @maguirja!

Can you give this curl a shot? If it doesn’t work, could you show me the verbose output? (minus any sensitive information)

curl -d "{\"query\": \"query { viewer { login } }\"}" --header "authorization:bearer <TOKEN>" -H "Accept: application/vnd.github.v4.idl" https://api.github.com/graphql -v

This is the curl that I typically use. The main differences I see between mine and yours are:

  1. bearer instead of token in the Authorization header
  2. the Accept header is required for the GraphQL API

Let me know if this works!