Skip to content

Instantly share code, notes, and snippets.

@ayodejiayodele
Last active June 6, 2024 01:37
Show Gist options
  • Save ayodejiayodele/869314a91465deb40482a91e65c3b42f to your computer and use it in GitHub Desktop.
Save ayodejiayodele/869314a91465deb40482a91e65c3b42f to your computer and use it in GitHub Desktop.
How to Retrieve Email Addresses from SAML Identity Provider

How to Retrieve Email Addresses from SAML SSO Identity Provider

Retrieve the email/login name of your developers on the GitHub Enterprise when authentication is through SAML SSO using your own identity provider such as Azure AD or Okta. The option you choose will depend on if you have single sign-on configured at the Organization level or at the Enterprise level.

You can try out the query first using the GraphQL Explorer before spending development effort.

Organization-Level SSO

query {
  organization(login: "<organization-name>") {
    samlIdentityProvider {
      ssoUrl
      externalIdentities(first: 100) {
        edges {
          node {
            guid
            samlIdentity {
              nameId
            }
            user {
              login
            }
          }
        }
      }
    }
  }
}

Enterprise-Level SSO

query {
  enterprise(slug: "<enterprise-slug>") {
    ownerInfo {
      samlIdentityProvider {
        externalIdentities(after: null, first: 100) {
          pageInfo {
            hasNextPage
            endCursor
          }
          edges {
            node {
              user {
                login
              }
              samlIdentity {
                nameId
              }
            }
          }
        }
      }
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment