组织成员的REST API端点
使用REST API管理组织中的成员资格。
列出失败的组织邀请
返回的哈希包含`failed_at`和`failed_reason`字段,分别表示邀请失败的时间和失败原因。
“列出失败的组织邀请”的细粒度访问令牌
此端点可以使用以下细粒度令牌类型::
细粒度令牌必须具有以下权限集:
- “成员”组织权限(读取)
“列出失败的组织邀请”的参数
名称,类型,描述 |
---|
accept 字符串建议设置为 |
名称,类型,描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
名称,类型,描述 |
---|
per_page 整数每页的结果数量(最大100)。更多信息,请参见“[在REST API中使用分页](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)”。 默认值: |
page 整数要获取的结果的页码。更多信息,请参见“[在REST API中使用分页](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)”。 默认值: |
“列出失败的组织邀请”的HTTP响应状态码
状态码 | 描述 |
---|---|
200 | OK |
404 | 资源未找到 |
“列出失败的组织邀请”的代码示例
请求示例
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/failed_invitations
响应
状态:200
[ { "id": 1, "login": "monalisa", "node_id": "MDQ6VXNlcjE=", "email": "[email protected]", "role": "direct_member", "created_at": "2016-11-30T06:46:10-08:00", "failed_at": "", "failed_reason": "", "inviter": { "login": "other_user", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/other_user_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/other_user", "html_url": "https://github.com/other_user", "followers_url": "https://api.github.com/users/other_user/followers", "following_url": "https://api.github.com/users/other_user/following{/other_user}", "gists_url": "https://api.github.com/users/other_user/gists{/gist_id}", "starred_url": "https://api.github.com/users/other_user/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/other_user/subscriptions", "organizations_url": "https://api.github.com/users/other_user/orgs", "repos_url": "https://api.github.com/users/other_user/repos", "events_url": "https://api.github.com/users/other_user/events{/privacy}", "received_events_url": "https://api.github.com/users/other_user/received_events", "type": "User", "site_admin": false }, "team_count": 2, "invitation_teams_url": "https://api.github.com/organizations/2/invitations/1/teams", "invitation_source": "member" } ]
列出待处理的组织邀请
返回的哈希包含一个`role`字段,该字段指的是组织邀请角色,其值可以是以下值之一:`direct_member`、`admin`、`billing_manager`或`hiring_manager`。如果被邀请者不是GitHub成员,则返回哈希中的`login`字段将为`null`。
“列出待处理的组织邀请”的细粒度访问令牌
此端点可以使用以下细粒度令牌类型::
细粒度令牌必须具有以下权限集:
- “成员”组织权限(读取)
“列出待处理的组织邀请”的参数
名称,类型,描述 |
---|
accept 字符串建议设置为 |
名称,类型,描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
名称,类型,描述 |
---|
per_page 整数每页的结果数量(最大100)。更多信息,请参见“[在REST API中使用分页](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)”。 默认值: |
page 整数要获取的结果的页码。更多信息,请参见“[在REST API中使用分页](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)”。 默认值: |
role 字符串按成员角色筛选邀请。 默认值: 可以是以下值之一: |
invitation_source 字符串按邀请来源筛选邀请。 默认值: 可以是以下值之一: |
“列出待处理的组织邀请”的HTTP响应状态码
状态码 | 描述 |
---|---|
200 | OK |
404 | 资源未找到 |
“列出待处理的组织邀请”的代码示例
请求示例
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/invitations
响应
状态:200
[ { "id": 1, "login": "monalisa", "node_id": "MDQ6VXNlcjE=", "email": "[email protected]", "role": "direct_member", "created_at": "2016-11-30T06:46:10-08:00", "failed_at": "", "failed_reason": "", "inviter": { "login": "other_user", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/other_user_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/other_user", "html_url": "https://github.com/other_user", "followers_url": "https://api.github.com/users/other_user/followers", "following_url": "https://api.github.com/users/other_user/following{/other_user}", "gists_url": "https://api.github.com/users/other_user/gists{/gist_id}", "starred_url": "https://api.github.com/users/other_user/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/other_user/subscriptions", "organizations_url": "https://api.github.com/users/other_user/orgs", "repos_url": "https://api.github.com/users/other_user/repos", "events_url": "https://api.github.com/users/other_user/events{/privacy}", "received_events_url": "https://api.github.com/users/other_user/received_events", "type": "User", "site_admin": false }, "team_count": 2, "invitation_teams_url": "https://api.github.com/organizations/2/invitations/1/teams", "invitation_source": "member" } ]
创建组织邀请
使用GitHub用户ID或电子邮件地址邀请人员加入组织。为了在组织中创建邀请,经过身份验证的用户必须是组织所有者。
此端点会触发[通知](https://docs.github.com/github/managing-subscriptions-and-notifications-on-github/about-notifications)。使用此端点创建内容过快可能会导致二次速率限制。更多信息,请参见“[API的速率限制](https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits)”和“[使用REST API的最佳实践](https://docs.github.com/rest/guides/best-practices-for-using-the-rest-api)”。
“创建组织邀请”的细粒度访问令牌
此端点可以使用以下细粒度令牌类型::
细粒度令牌必须具有以下权限集:
- “成员”组织权限(写入)
“创建组织邀请”的参数
名称,类型,描述 |
---|
accept 字符串建议设置为 |
名称,类型,描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
名称,类型,描述 |
---|
invitee_id 整数**除非提供 |
email 字符串**除非提供 |
role 字符串新成员的角色。
默认值: 可以是以下值之一: |
team_ids 整数数组指定要邀请新成员加入的团队的ID。 |
“创建组织邀请”的HTTP响应状态码
状态码 | 描述 |
---|---|
201 | 已创建 |
404 | 资源未找到 |
422 | 验证失败,或端点已被垃圾邮件攻击。 |
“创建组织邀请”的代码示例
请求示例
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/invitations \ -d '{"email":"[email protected]","role":"direct_member","team_ids":[12,26]}'
响应
状态:201
{ "id": 1, "login": "monalisa", "node_id": "MDQ6VXNlcjE=", "email": "[email protected]", "role": "direct_member", "created_at": "2016-11-30T06:46:10-08:00", "inviter": { "login": "other_user", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/other_user_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/other_user", "html_url": "https://github.com/other_user", "followers_url": "https://api.github.com/users/other_user/followers", "following_url": "https://api.github.com/users/other_user/following{/other_user}", "gists_url": "https://api.github.com/users/other_user/gists{/gist_id}", "starred_url": "https://api.github.com/users/other_user/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/other_user/subscriptions", "organizations_url": "https://api.github.com/users/other_user/orgs", "repos_url": "https://api.github.com/users/other_user/repos", "events_url": "https://api.github.com/users/other_user/events{/privacy}", "received_events_url": "https://api.github.com/users/other_user/received_events", "type": "User", "site_admin": false }, "team_count": 2, "invitation_teams_url": "https://api.github.com/organizations/2/invitations/1/teams", "invitation_source": "member" }
取消组织邀请
取消组织邀请。为了取消组织邀请,经过身份验证的用户必须是组织所有者。
此端点会触发通知。
“取消组织邀请”的细粒度访问令牌
此端点可以使用以下细粒度令牌类型::
细粒度令牌必须具有以下权限集:
- “成员”组织权限(写入)
“取消组织邀请”的参数
名称,类型,描述 |
---|
accept 字符串建议设置为 |
名称,类型,描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
invitation_id 整数 必填邀请的唯一标识符。 |
“取消组织邀请”的HTTP响应状态码
状态码 | 描述 |
---|---|
204 | 无内容 |
404 | 资源未找到 |
422 | 验证失败,或端点已被垃圾邮件攻击。 |
“取消组织邀请”的代码示例
请求示例
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/invitations/INVITATION_ID
响应
状态:204
列出组织邀请团队
列出与邀请关联的所有团队。为了查看组织中的邀请,经过身份验证的用户必须是组织所有者。
“列出组织邀请团队”的细粒度访问令牌
此端点可以使用以下细粒度令牌类型::
细粒度令牌必须具有以下权限集:
- “成员”组织权限(读取)
“列出组织邀请团队”的参数
名称,类型,描述 |
---|
accept 字符串建议设置为 |
名称,类型,描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
invitation_id 整数 必填邀请的唯一标识符。 |
名称,类型,描述 |
---|
per_page 整数每页的结果数量(最大100)。更多信息,请参见“[在REST API中使用分页](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)”。 默认值: |
page 整数要获取的结果的页码。更多信息,请参见“[在REST API中使用分页](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)”。 默认值: |
“列出组织邀请团队”的HTTP响应状态码
状态码 | 描述 |
---|---|
200 | OK |
404 | 资源未找到 |
“列出组织邀请团队”的代码示例
请求示例
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/invitations/INVITATION_ID/teams
响应
状态:200
[ { "id": 1, "node_id": "MDQ6VGVhbTE=", "url": "https://api.github.com/teams/1", "html_url": "https://github.com/orgs/github/teams/justice-league", "name": "Justice League", "slug": "justice-league", "description": "A great team.", "privacy": "closed", "notification_setting": "notifications_enabled", "permission": "admin", "members_url": "https://api.github.com/teams/1/members{/member}", "repositories_url": "https://api.github.com/teams/1/repos", "parent": null } ]
列出组织成员
列出所有属于某个组织的用户。如果经过身份验证的用户也是此组织的成员,则会返回隐藏成员和公共成员。
“列出组织成员”的细粒度访问令牌
此端点可以使用以下细粒度令牌类型::
细粒度令牌必须具有以下权限集:
- “成员”组织权限(读取)
如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。
“列出组织成员”的参数
名称,类型,描述 |
---|
accept 字符串建议设置为 |
名称,类型,描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
名称,类型,描述 |
---|
filter 字符串筛选列表中返回的成员。 默认值: 可以是以下之一: |
role 字符串按其角色筛选返回的成员。 默认值: 可以是以下之一: |
per_page 整数每页的结果数量(最大100)。更多信息,请参见“[在REST API中使用分页](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)”。 默认值: |
page 整数要获取的结果的页码。更多信息,请参见“[在REST API中使用分页](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)”。 默认值: |
“列出组织成员”的HTTP响应状态码
状态码 | 描述 |
---|---|
200 | OK |
422 | 验证失败,或端点已被垃圾邮件攻击。 |
“列出组织成员”的代码示例
请求示例
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/members
响应
状态:200
[ { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false } ]
检查用户的组织成员资格
检查用户是公开还是私下地成为组织的成员。
“检查用户的组织成员资格”的细粒度访问令牌
此端点可以使用以下细粒度令牌类型::
细粒度令牌必须具有以下权限集:
- “成员”组织权限(读取)
如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。
“检查用户的组织成员资格”的参数
名称,类型,描述 |
---|
accept 字符串建议设置为 |
名称,类型,描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
username 字符串 必填GitHub 用户帐户的用户名。 |
“检查用户的组织成员资格”的HTTP响应状态码
状态码 | 描述 |
---|---|
204 | 如果请求者是组织成员且用户是成员 |
302 | 如果请求者不是组织成员 |
404 | 如果请求者是组织成员且用户不是成员,则返回“未找到” |
“检查用户的组织成员资格”的代码示例
请求示例
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/members/USERNAME
如果请求者是组织成员且用户是成员
状态:204
移除组织成员
从此列表中移除用户会将其从所有团队中移除,并且他们将不再访问组织的存储库。
“移除组织成员”的细粒度访问令牌
此端点可以使用以下细粒度令牌类型::
细粒度令牌必须具有以下权限集:
- “成员”组织权限(写入)
“移除组织成员”的参数
名称,类型,描述 |
---|
accept 字符串建议设置为 |
名称,类型,描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
username 字符串 必填GitHub 用户帐户的用户名。 |
“移除组织成员”的HTTP响应状态码
状态码 | 描述 |
---|---|
204 | 无内容 |
403 | 禁止 |
“移除组织成员”的代码示例
请求示例
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/members/USERNAME
响应
状态:204
获取用户的组织成员资格
为了获取用户的组织成员资格,经过身份验证的用户必须是组织成员。响应中的state
参数可用于标识用户的成员资格状态。
“获取用户的组织成员资格”的细粒度访问令牌
此端点可以使用以下细粒度令牌类型::
细粒度令牌必须具有以下权限集:
- “成员”组织权限(读取)
“获取用户的组织成员资格”的参数
名称,类型,描述 |
---|
accept 字符串建议设置为 |
名称,类型,描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
username 字符串 必填GitHub 用户帐户的用户名。 |
“获取用户的组织成员资格”的HTTP响应状态码
状态码 | 描述 |
---|---|
200 | OK |
403 | 禁止 |
404 | 资源未找到 |
“获取用户的组织成员资格”的代码示例
请求示例
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/memberships/USERNAME
如果用户拥有组织的活动管理员成员资格
状态:200
{ "url": "https://api.github.com/orgs/octocat/memberships/defunkt", "state": "active", "role": "admin", "organization_url": "https://api.github.com/orgs/octocat", "organization": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" }, "user": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false } }
设置用户的组织成员资格
只有经过身份验证的组织所有者才能将成员添加到组织或更新成员的角色。
-
如果经过身份验证的用户正在添加组织成员,则被邀请的用户会收到一封电子邮件,邀请他们加入组织。在他们接受邀请之前,用户的成员资格状态将为
pending
。 -
经过身份验证的用户可以通过传递
role
参数来更新用户的成员资格。如果经过身份验证的用户将成员的角色更改为admin
,则受影响的用户会收到一封电子邮件,通知他们已被提升为组织所有者。如果经过身份验证的用户将所有者的角色更改为member
,则不会发送电子邮件。
速率限制
为防止滥用,组织所有者在一个24小时内最多只能为一个组织创建50个组织邀请。如果组织成立超过一个月或使用付费计划,则每24小时的邀请限制为500个。
“设置用户的组织成员资格”的细粒度访问令牌
此端点可以使用以下细粒度令牌类型::
细粒度令牌必须具有以下权限集:
- “成员”组织权限(写入)
“设置用户的组织成员资格”的参数
名称,类型,描述 |
---|
accept 字符串建议设置为 |
名称,类型,描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
username 字符串 必填GitHub 用户帐户的用户名。 |
名称,类型,描述 |
---|
role 字符串赋予用户在组织中的角色。可以是以下之一
默认值: 可以是以下之一: |
“设置用户的组织成员资格”的HTTP响应状态码
状态码 | 描述 |
---|---|
200 | OK |
403 | 禁止 |
422 | 验证失败,或端点已被垃圾邮件攻击。 |
“设置用户的组织成员资格”的代码示例
请求示例
curl -L \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/memberships/USERNAME \ -d '{"role":"member"}'
如果用户拥有组织的活动管理员成员资格
状态:200
{ "url": "https://api.github.com/orgs/octocat/memberships/defunkt", "state": "active", "role": "admin", "organization_url": "https://api.github.com/orgs/octocat", "organization": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" }, "user": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false } }
移除用户的组织成员资格
为了移除用户的组织成员资格,经过身份验证的用户必须是组织所有者。
如果指定用户是组织的活动成员,这将将其从组织中移除。如果指定用户已被邀请加入组织,这将取消其邀请。这两种情况下,指定用户都会收到电子邮件通知。
“移除用户的组织成员资格”的细粒度访问令牌
此端点可以使用以下细粒度令牌类型::
细粒度令牌必须具有以下权限集:
- “成员”组织权限(写入)
“移除用户的组织成员资格”的参数
名称,类型,描述 |
---|
accept 字符串建议设置为 |
名称,类型,描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
username 字符串 必填GitHub 用户帐户的用户名。 |
“移除用户的组织成员资格”的HTTP响应状态码
状态码 | 描述 |
---|---|
204 | 无内容 |
403 | 禁止 |
404 | 资源未找到 |
“移除用户的组织成员资格”的代码示例
请求示例
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/memberships/USERNAME
响应
状态:204
列出公共组织成员
组织成员可以选择公开或不公开其成员身份。
“列出公共组织成员”的细粒度访问令牌
此端点可以使用以下细粒度令牌类型::
细粒度令牌必须具有以下权限集:
- “成员”组织权限(读取)
如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。
“列出公共组织成员”的参数
名称,类型,描述 |
---|
accept 字符串建议设置为 |
名称,类型,描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
名称,类型,描述 |
---|
per_page 整数每页的结果数量(最大100)。更多信息,请参见“[在REST API中使用分页](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)”。 默认值: |
page 整数要获取的结果的页码。更多信息,请参见“[在REST API中使用分页](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)”。 默认值: |
“列出公共组织成员”的HTTP响应状态码
状态码 | 描述 |
---|---|
200 | OK |
“列出公共组织成员”的代码示例
请求示例
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/public_members
响应
状态:200
[ { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false } ]
检查用户的公共组织成员身份
检查提供的用户是否是组织的公共成员。
“检查用户的公共组织成员身份”的细粒度访问令牌
此端点可以使用以下细粒度令牌类型::
细粒度令牌必须具有以下权限集:
- “成员”组织权限(读取)
如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。
“检查用户的公共组织成员身份”的参数
名称,类型,描述 |
---|
accept 字符串建议设置为 |
名称,类型,描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
username 字符串 必填GitHub 用户帐户的用户名。 |
“检查用户的公共组织成员身份”的HTTP响应状态码
状态码 | 描述 |
---|---|
204 | 如果用户是公共成员,则返回响应 |
404 | 如果用户不是公共成员,则返回“未找到” |
“检查用户的公共组织成员身份”的代码示例
请求示例
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/public_members/USERNAME
如果用户是公共成员,则返回响应
状态:204
设置已认证用户的公共组织成员身份
用户可以公开自己的成员身份。(用户不能公开其他用户的成员身份。)
请注意,调用此端点时,您需要将Content-Length
设置为零。有关更多信息,请参见“HTTP方法”。
“设置已认证用户的公共组织成员身份”的细粒度访问令牌
此端点可以使用以下细粒度令牌类型::
细粒度令牌必须具有以下权限集:
- “成员”组织权限(写入)
“设置已认证用户的公共组织成员身份”的参数
名称,类型,描述 |
---|
accept 字符串建议设置为 |
名称,类型,描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
username 字符串 必填GitHub 用户帐户的用户名。 |
“设置已认证用户的公共组织成员身份”的HTTP响应状态码
状态码 | 描述 |
---|---|
204 | 无内容 |
403 | 禁止 |
“设置已认证用户的公共组织成员身份”的代码示例
请求示例
curl -L \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/public_members/USERNAME
响应
状态:204
删除已认证用户的公共组织成员身份
除非默认情况下强制执行公开可见性,否则将删除已认证用户在指定组织中的公共成员身份。
“删除已认证用户的公共组织成员身份”的细粒度访问令牌
此端点可以使用以下细粒度令牌类型::
细粒度令牌必须具有以下权限集:
- “成员”组织权限(写入)
“删除已认证用户的公共组织成员身份”的参数
名称,类型,描述 |
---|
accept 字符串建议设置为 |
名称,类型,描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
username 字符串 必填GitHub 用户帐户的用户名。 |
“删除已认证用户的公共组织成员身份”的HTTP响应状态码
状态码 | 描述 |
---|---|
204 | 无内容 |
“删除已认证用户的公共组织成员身份”的代码示例
请求示例
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/public_members/USERNAME
响应
状态:204
列出已认证用户的组织成员身份
列出已认证用户的所有组织成员身份。
“列出已认证用户的组织成员身份”的细粒度访问令牌
此端点可以使用以下细粒度令牌类型::
细粒度令牌不需要任何权限。
“列出已认证用户的组织成员身份”的参数
名称,类型,描述 |
---|
accept 字符串建议设置为 |
名称,类型,描述 |
---|
state 字符串指示要返回的成员身份状态。如果未指定,则API将返回活动和待处理的成员身份。 可以是: |
per_page 整数每页的结果数量(最大100)。更多信息,请参见“[在REST API中使用分页](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)”。 默认值: |
page 整数要获取的结果的页码。更多信息,请参见“[在REST API中使用分页](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)”。 默认值: |
“列出已认证用户的组织成员身份”的HTTP响应状态码
状态码 | 描述 |
---|---|
200 | OK |
304 | 未修改 |
401 | 需要身份验证 |
403 | 禁止 |
422 | 验证失败,或端点已被垃圾邮件攻击。 |
“列出已认证用户的组织成员身份”的代码示例
请求示例
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/user/memberships/orgs
响应
状态:200
[ { "url": "https://api.github.com/orgs/octocat/memberships/defunkt", "state": "active", "role": "admin", "organization_url": "https://api.github.com/orgs/octocat", "organization": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" }, "user": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false } }, { "url": "https://api.github.com/orgs/invitocat/memberships/defunkt", "state": "pending", "role": "admin", "organization_url": "https://api.github.com/orgs/invitocat", "organization": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" }, "user": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false } } ]
获取已认证用户的组织成员身份
如果已认证用户是组织的活动成员或待处理成员,则此端点将返回用户的成员身份。如果已认证用户与组织无关,则返回404
。如果由组织阻止的GitHub App发出请求,则此端点将返回403
。
“获取已认证用户的组织成员身份”的细粒度访问令牌
此端点可以使用以下细粒度令牌类型::
细粒度令牌必须具有以下权限集:
- “成员”组织权限(读取)
“获取已认证用户的组织成员身份”的参数
名称,类型,描述 |
---|
accept 字符串建议设置为 |
名称,类型,描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
“获取已认证用户的组织成员身份”的HTTP响应状态码
状态码 | 描述 |
---|---|
200 | OK |
403 | 禁止 |
404 | 资源未找到 |
“获取已认证用户的组织成员身份”的代码示例
请求示例
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/user/memberships/orgs/ORG
响应
状态:200
{ "url": "https://api.github.com/orgs/invitocat/memberships/defunkt", "state": "pending", "role": "admin", "organization_url": "https://api.github.com/orgs/invitocat", "organization": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" }, "user": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false } }
更新已认证用户的组织成员身份
如果该用户有来自组织的待处理邀请,则将其转换为组织的活动成员。
“更新已认证用户的组织成员身份”的细粒度访问令牌
此端点可以使用以下细粒度令牌类型::
细粒度令牌必须具有以下权限集:
- “成员”组织权限(写入)
“更新已认证用户的组织成员身份”的参数
名称,类型,描述 |
---|
accept 字符串建议设置为 |
名称,类型,描述 |
---|
org 字符串 必需组织名称。名称不区分大小写。 |
名称,类型,描述 |
---|
state 字符串 必填成员身份应处的状态。只接受 值: |
“更新已认证用户的组织成员身份”的HTTP响应状态码
状态码 | 描述 |
---|---|
200 | OK |
403 | 禁止 |
404 | 资源未找到 |
422 | 验证失败,或端点已被垃圾邮件攻击。 |
“更新已认证用户的组织成员身份”的代码示例
请求示例
curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/user/memberships/orgs/ORG \ -d '{"state":"active"}'
响应
状态:200
{ "url": "https://api.github.com/orgs/octocat/memberships/defunkt", "state": "active", "role": "admin", "organization_url": "https://api.github.com/orgs/octocat", "organization": { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" }, "user": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false } }