Gists API empty result for Private Profiles #44797
Replies: 2 comments
-
|
looks like for private profiles the solution is to use authentication as per https://docs.github.com/en/rest/gists/gists?apiVersion=2022-11-28#list-gists-for-the-authenticated-user using a generic or fine-grained access token: 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/gistswith python import requests
# assuming you have defined `user` as the github user name
resp = requests.get(f'https://api.github.com/users/{user}/gists', headers={
"Accept": "application/vnd.github+json",
"Authorization": "Bearer <YOUR-TOKEN>",
"X-GitHub-Api-Version": "2022-11-28",
})
for gist in resp.json():
print(gist)Clone gist with
|
Beta Was this translation helpful? Give feedback.
-
|
import requests assuming you have defined
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Bug
Body
Under Github user settings, the option to
Make profile private and hide activityis available. When enabling Private Profile, the Github Gists API returns an empty array.Certainly this is a bug, given that the Repos API still returns all of my public repos, even when Private Profile is enabled. If I visit my Gists profile (not logged in), I can still see all of my public gists either way.
With private mode DISABLED, the API returns (abbreviated result):
[ { "url": "https://api.github.com/gists/31f843122783508fbb227c491eea9665", "forks_url": "https://api.github.com/gists/31f843122783508fbb227c491eea9665/forks", "commits_url": "https://api.github.com/gists/31f843122783508fbb227c491eea9665/commits", "id": "31f843122783508fbb227c491eea9665", "node_id": "G_kwDOAklLb9oAIDMxZjg0MzEyMjc4MzUwOGZiYjIyN2M0OTFlZWE5NjY1", "git_pull_url": "https://gist.github.com/31f843122783508fbb227c491eea9665.git", "git_push_url": "https://gist.github.com/31f843122783508fbb227c491eea9665.git", "html_url": "https://gist.github.com/31f843122783508fbb227c491eea9665", "files": { "RepairOrder.php": { "filename": "RepairOrder.php", "type": "application/x-httpd-php", "language": "PHP", "raw_url": "https://gist.githubusercontent.com/amattu2/31f843122783508fbb227c491eea9665/raw/d11c3fe179acfb4b1b91d4b374d66b6c774c0bc1/RepairOrder.php", "size": 11101 } } } ]With private mode ENABLED, the API returns:
Beta Was this translation helpful? Give feedback.
All reactions