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

时间:2016-09-24 01:22:48

标签: github github-api

如何找到我的GitHub组织ID?

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

2 个答案:

答案 0 :(得分:4)

the Organization API,访问

https://api.github.com/orgs?access_token=OAUTH-TOKEN

或输入:

curl -H "Authorization: token OAUTH-TOKEN" https://api.github.com/orgs

(用您自己的GitHub访问令牌替换OAUTH-TOKEN:请参阅“Git automation with OAuth tokens”以获取或创建PAT:个人访问令牌

您可以在下面找到多个组织。

每一个:

curl -H "Accept: application/json" -H "Authorization: token OAUTH-TOKEN" https://api.github.com/orgs/<anorg> | jq ".id"

使用jq (lightweight command-line JSON processor,包括Windows可用for all OS,您将直接获得ID。

答案 1 :(得分:2)

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

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/app_bar_main"
    tools:context=".MainActivity">


        <fragment xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/map"
            android:layout_alignParentBottom="true"
            tools:context=".MapsActivity"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            tools:layout="@layout/abc_action_bar_up_container"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Get Me Somewhere"
        android:id="@+id/button"
        android:background="#5368ed"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="31dp"
        />

</RelativeLayout>

此命令输出如下:

curl -H "Authorization: token personal-access-token" https://api.github.com/orgs/name-of-your-org

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

{
  "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
  }
}

希望能帮到别人。