如何在github上找到我的组织ID?

Arb*_*zar 2 github github-api

如何找到我的GitHub组织ID?

理想情况下,我可以通过脚本或命令来解析其输出。

Von*_*onC 6

组织API,请访问:

https://api.github.com/orgs?access_token=OAUTH-TOKEN
Run Code Online (Sandbox Code Playgroud)

或输入:

curl -H "Authorization: token OAUTH-TOKEN" https://api.github.com/orgs
Run Code Online (Sandbox Code Playgroud)

(用OAUTH-TOKEN您自己的GitHub访问令牌替换:请参阅“ 使用OAuth令牌进行Git自动化 ”以获取或创建PAT:个人访问令牌)

您会发现,您可以在一个以上的组织中工作。

每一个人:

curl -H "Accept: application/json" -H "Authorization: token OAUTH-TOKEN" https://api.github.com/orgs/<anorg> | jq ".id"
Run Code Online (Sandbox Code Playgroud)

使用jq(轻量级命令行JSON处理器,可用于包括Windows在内的所有操作系统),您将直接获得ID。


Arb*_*zar 6

您可以使用以下命令找到它:

curl -H "Authorization: token personal-access-token" https://api.github.com/orgs/name-of-your-org
Run Code Online (Sandbox Code Playgroud)

该命令输出如下所示:

{
  "login": "your-org",
  "id": 15156947,
  "url": "https://api.github.com/orgs/your-org",
  "repos_url": "https://api.github.com/orgs/your-org/repos",
  "events_url": "https://api.github.com/orgs/your-org/events",
  "hooks_url": "https://api.github.com/orgs/your-org/hooks",
  "issues_url": "https://api.github.com/orgs/your-org/issues",
  "members_url": "https://api.github.com/orgs/your-org/members{/member}",
  "public_members_url": "https://api.github.com/orgs/your-org/public_members{/member}",
  "avatar_url": "https://avatars.githubusercontent.com/u/15056937?v=3",
  "description": "",
  "name": "",
  "company": null,
  "blog": "",
  "location": "",
  "email": "",
  "public_repos": 1,
  "public_gists": 0,
  "followers": 0,
  "following": 0,
  "html_url": "https://github.com/your-org",
  "created_at": "2013-11-09T21:58:06Z",
  "updated_at": "2014-09-18T16:54:44Z",
  "type": "Organization",
  "total_private_repos": 0,
  "owned_private_repos": 0,
  "private_gists": 0,
  "disk_usage": 0,
  "collaborators": 0,
  "billing_email": "example@mail.com",
  "plan": {
    "name": "free",
    "space": 976562499,
    "private_repos": 0,
    "filled_seats": 2,
    "seats": 0
  }
}
Run Code Online (Sandbox Code Playgroud)

因此第二行包含所需的组织 ID:

"id": 15156947
Run Code Online (Sandbox Code Playgroud)

希望对其他人有帮助。