我想使用 GitHub API(任何版本)获取组织中 GitHub 登录名和电子邮件之间的映射。
我可以使用以下 GraphQL 查询获取组织成员帐户上的电子邮件:
query {
organization(login:"myorg"){
members(first:100) {
nodes {
login
name
email
}
}
}
}
但这不是我想要的电子邮件。我确实想要有关“链接的 SSO 身份”的电子邮件,我可以通过单击以下链接从我的组织页面访问该电子邮件:
当我单击此链接时,所需的电子邮件会列在https://github.com/orgs/myorg/people/danvk/sso https://github.com/orgs/myorg/people/danvk/sso.
是否可以通过任何版本的 GitHub API 访问此 SSO 链接的电子邮件?
组织级 SAML
您可以访问通过 SCIM* 配置的帐户的此信息。
query {
organization(login: "LOGIN") {
samlIdentityProvider {
ssoUrl
externalIdentities(first: 100) {
edges {
node {
guid
samlIdentity {
nameId
}
user {
login
}
}
}
}
}
}
}
[由 GitHub 支持人员编写] 和可用示例here https://github.com/github/platform-samples/issues/168.
- 我尚未验证在 SCIM 之外链接了 SAML 帐户的帐户是否可以使用此查询。
企业级 SAML
如果您的 IdP 在企业级别配置,请改为运行:
{
enterprise(slug: "MYENTERPRISENAME") {
ownerInfo {
samlIdentityProvider {
externalIdentities(after: null, first: 100) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
user {
login
}
samlIdentity {
nameId
}
}
}
}
}
}
}
}
附加信息
这些 GraphQL 查询可以通过 GitHub CLI 运行(在这里下载 https://cli.github.com/).
权限由个人访问令牌 (PAT) 提供。您可以将其设置为https://github.com/settings/tokens https://github.com/settings/tokens.
- 如果查询组织,您需要将 PAT 分配给
admin:org
正确的。您还需要为您打算使用它的每个组织进行授权(通过Configure SSO
PAT 旁边的选项。
- 如果查询企业,您需要将您的 PAT 分配给
admin:enterprise
right.
要验证创建环境变量,GH_TOKEN
,并将其值设置为令牌的值(如果您在创建令牌时没有注意到这一点,则必须删除并重新创建令牌才能获得新值)。
如何使用的示例gh
可以在此处找到运行 graphql(和其他 API)查询的 cli:https://cli.github.com/manual/gh_api https://cli.github.com/manual/gh_api
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)