2

As title, I'm using Github GraphQL explorer to fetch list of my gists.

query {
  viewer {
    gists(first:5, privacy:ALL) {
            edges {
                node {
                    id
                    description
                    name
                    pushedAt
                }
            }
        }
  }
}

Everything works fine except that the secret gists are not included in the response. When I tried to fetch secret gists by changing the GistPrivacy from ALL to SECRET as below:

query {
  viewer {
    gists(first:5, privacy:SECRET) {
            edges {
                node {
                    id
                    description
                    name
                    pushedAt
                }
            }
        }
  }
}

The following permission error occurred:

{
  "data": {
    "viewer": {
      "gists": {
        "edges": []
      }
    }
  },
  "errors": [
    {
      "message": "You don't have permission to see gists."
    }
  ]
}

I wonder is there any way to solve this problem. I noticed that there was a related questions with irrelevant answer asked 5 years ago.

Any comment or help is much appreciated, thanks in advance.

1 Answer 1

3

As it turns out, although one can't get the secret gists from the Github GraphQL explorer directly, by creating a Personal Access Tokens and using it to access the GraphQL API, one can get the secret gists.

enter image description here

The equivalent curl command is as following:

curl --request POST \
  --url https://api.github.com/graphql \
  --header 'authorization: Bearer YOUR_PERSONAL_ACCESS_TOKEN' \
  --header 'content-type: application/json' \
  --data '{"query":"query {\n  viewer {\n    gists(first:5, privacy:ALL) {\n\t\t\tedges {\n\t\t\t\tnode {\n\t\t\t\t\tid\n\t\t\t\t\tdescription\n\t\t\t\t\tname\n\t\t\t\t\tpushedAt\n\t\t\t\t}\n\t\t\t}\n\t\t}\n  }\n}"}'
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.