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

Token works but getting 'Error from GitHub API: Bad credentials' #2

Open
Cammac7 opened this issue Jul 10, 2017 · 6 comments
Open

Token works but getting 'Error from GitHub API: Bad credentials' #2

Cammac7 opened this issue Jul 10, 2017 · 6 comments

Comments

@Cammac7
Copy link

Cammac7 commented Jul 10, 2017

@benwtr thanks for the enterprise token help.
I'm getting the "bad credentials" error above, but have verified that my token is valid.

I start my hubot like: HUBOT_GITHUB_TOKEN_FERNET_SECRETS={my token fernet secret} HUBOT_GH_ISSUES_DEFAULT_OWNER={email address to my GitHub enterprise account (from where the oath token is generated)} HUBOT_GH_ISSUES_DEFAULT_REPO={organization name} ./bin/hubot

If I run hubot github token verify it returns: "Your GitHub token is valid on github.{my enterprise}.com."

But if I run hubot github show issue #247 I get the error Hubot> Shell: Error from GitHub API: Bad credentials. Have I done something wrong? or any thoughts on how I can start debugging this/looking?

@Cammac7 Cammac7 changed the title Token works but getting Hubot> Shell: Error from GitHub API: Bad credentials Token works but getting 'Error from GitHub API: Bad credentials' Jul 10, 2017
@benwtr
Copy link
Member

benwtr commented Jul 10, 2017

Have I done something wrong?

Yes but it's probably my fault for not documenting it better.

HUBOT_GH_ISSUES_DEFAULT_OWNER={email address to my GitHub enterprise account (from where the oath token is generated)}
HUBOT_GH_ISSUES_DEFAULT_REPO={organization name}

Think of it as https://github.com/HUBOT_GH_ISSUES_DEFAULT_OWNER/HUBOT_GH_ISSUES_DEFAULT_REPO

Or whatever the domain is for your GH Enterprise.

Note that these are "DEFAULT" values, meaning they are the default target for the issues. Users can tell hubot to read and write issues in a different repo if they wish.

By the way, this script never really caught on in my org so it hasn't been very well tested. People found the patterns impossible to remember and such a hassle to get correct that it was so much easier to open a browser instead. So feel free to try to improve that

@Cammac7
Copy link
Author

Cammac7 commented Jul 11, 2017

@benwtr great, thanks for that! And yea I see what you mean. Luckily I'm focused around one repo, so I'm thinking it will come in handy for my team. If they find difficulty, I look forward to making a pull request that will allow some more flexible input terms/interpretation. Again, thank you so much for all of the help. Look forward to playing with this.

@Cammac7
Copy link
Author

Cammac7 commented Jul 12, 2017

@benwtr I'm definitely a niche issue since a GitHub enterprise API exists at http(s)://hostname/api/v3/
So for accessing issues using a get request to the API in other scripts I've written I use:
https://hostname/api/v3/repos/{organization}/{repo}/issues?access_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

If I ever get this working I'll be sure to try to make a branch for using GitHub enterprise with it!

@benwtr
Copy link
Member

benwtr commented Jul 13, 2017

I used a library called octonode to talk to github. Here is how you create a client with it and connect it to a non-default host such as GH Enterprise: https://github.com/pksunkara/octonode#build-a-client-from-a-different-host

Take a look at https://github.com/hubot-scripts/hubot-gh-issues/blob/master/index.coffee

The lines where it creates a client: client = github.client token, you would need to pass in the hostname there, something like:

client = github.client(token, { hostname: 'yourgithub.enterprise.com/api/v3' })

You could use an environment variable instead of hardcoding the hostname, of course.

@Cammac7
Copy link
Author

Cammac7 commented Jul 18, 2017

Man, I can not, for the life of me get away from this Shell: Error from GitHub API: Bad credentials error.
I tried hardcoding in the hostname. Is there a way to check the actual credentials? (Like, I can't tell if it's my path that's formatted incorrectly, or if it's the actual credentials.

@benwtr
Copy link
Member

benwtr commented Jul 18, 2017

Sticking a bunch of console.log some_variable lines in the code temporarily can go a long way.

If you want, you can try this slack. there's a #chatops room and someone there be able to help you out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants