hubot-archive / hubot-gh-token

Stores GitHub Personal Access Tokens in Hubot's brain
4 stars 2 forks source link

Does this work with GitHub enterprise? #1

Closed Cammac7 closed 7 years ago

Cammac7 commented 7 years ago

I'm trying to connect my hubot to a GitHub enterprise account so that I can use https://github.com/hubot-scripts/hubot-gh-issues

I've generated a personal access token within the GitHub enterprise account that has full access to everything. Unfortunately when I run hubot github token set xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx The hubot just returns: Your GitHub token is invalid, verify that it has 'repo' scope.

I've explored gh-token.coffee but can't see where I'm going wrong. I also generated a HUBOT_GITHUB_TOKEN_FERNET_SECRETS and initialized the hubot with that value set, and still get the error that my token is invalid. Is there anything else I need to set, such as a user or enterprise domain for the hubot to look? @benwtr

benwtr commented 7 years ago

Hi @Cammac7 !

I've never tried it with GitHub enterprise but it's in the code:

  apiUri: ->
    (@application? and @application['github_api']) or
      process.env.HUBOT_GITHUB_API or
      'https://api.github.com'

It's there because I stole it from hubot-deploy.

Setting the HUBOT_GITHUB_API environment variable to the url for your github enterprise API and it'll probably work. 😉

Take a look at https://github.com/ys/hubot-vault for an explanation of HUBOT_GITHUB_TOKEN_FERNET_SECRETS if that part is unclear. tl;dr it adds basic symmetrical encryption for the secrets and that variable is the key.

Cammac7 commented 7 years ago

@benwtr thanks! That worked. Still can't get https://github.com/hubot-scripts/hubot-gh-issues working, but your fix got me able to use hubby-gh-token with no issues! Thanks much! I'll close this one and open one in hub-gh-issues