103

I have created an organization on GitHub. My organization has some repos. These repos have API documentation that I would like to re-build and publish to gh-pages branch via Travis-CI. In order to give Travis-CI access to my organization's repos I need to generate an OAuth token, encrypt it, and then add then include the encypted token in the .travis.yml file as follows...

env:
  global:
  - secure: "lots-of-seemingly-random-characters"

This SO post explains the process and provides the details on how to do this for user accounts. How do I generate the required OAuth token for organization accounts?

Community
  • 1
  • 1
davidrpugh
  • 4,363
  • 5
  • 32
  • 46
  • 1
    Seems like [on `gitlab.com` this isn't possible](https://gitlab.com/gitlab-org/gitlab-ce/issues/37778) either. – IsaacS Oct 31 '17 at 22:00
  • For access to a specific org-level repository, a [deploy-key](https://stackoverflow.com/a/72414537/6813271) may be a viable alternative to a token. – Rene Hamburger Aug 17 '23 at 11:11

1 Answers1

130

That's not possible currently, you can only create tokens for user accounts since user accounts have permissions associated with them (organizations don't). So, you'd need to create a token with an account which has access to the repository in question and give that to Travis. You can also create a machine account for that purpose.

Ivan Zuzak
  • 18,068
  • 3
  • 69
  • 61
  • 14
    Do you have any plan to support this? – yanana Apr 07 '16 at 07:49
  • 56
    So if the user associated with these accounts leaves the organization we would have to replace all of the tokens in our travis files? Is this intentionally not supported, or just not yet supported? – justin.m.chase Jun 13 '16 at 20:53
  • 2
    What is a "machine account", I can't seem to find documentation on this. – justin.m.chase Jun 13 '16 at 20:54
  • 2
    Nevermind, I see its just an account that is created specifically for use by the org for automation. Nothing fancy. – justin.m.chase Jun 13 '16 at 21:07
  • 15
    About "machine account": https://developer.github.com/guides/managing-deploy-keys/#machine-users – Huang C. Mar 23 '17 at 03:49
  • 28
    Problem is that machine account takes up a seat in the organization. – Alex Barker Feb 02 '20 at 21:49
  • 11
    hi, is there any update on the org token? – Jirka Nov 30 '20 at 17:01
  • https://micahjon.com/2021/repo-scoped-access-token-for-github-org/ – Juraj Martinka Sep 23 '22 at 13:12
  • 1
    As of Nov 2022, the solution is to use GitHub Apps as per [the documentation](https://docs.github.com/en/enterprise-server@3.4/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#about-personal-access-tokens): > Personal access tokens are intended to access GitHub resources on behalf of yourself. To access resources on behalf of an organization, or for long-lived integrations, you should use a GitHub App.. – Rafs Nov 30 '22 at 12:07