GraphQL and OAuth Access Restrictions

Hi,

executing a query like 

query($pageSize: Int!, $owner: String!) {
  repositoryOwner(login: $owner) {
    ...on Organization {
      repositories(first: $pageSize, ownerAffiliations: [OWNER]) {
        totalCount
        edges {
          node {
            name
          }
        }
        pageInfo {
          endCursor
          hasNextPage
        }
      }
    }
  }
}

results in an error if the target organization has OAuth Access restrictions enabled:

Although you appear to have the correct authorization credentials, the `ORGANIZATION_NAME` organization has enabled OAuth App access restrictions, meaning that data access to third-parties is limited. [...]

This is confusing since we can retrieve the information that the user is in given organization via the API in the first place. It is unclear for us how the API should be used in the context of OAuth Access restrictions.

Right now it seems that we have to trial and error for all organizations on whether there is an error message which is cumbersome. Further it makes it impossible to reliably query multiple organizations at once. Insight on this would be much appreciated.

4 Likes