10000 Require auth for creating gists (#802) · staticdev/github4.py@2aa1748 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on May 22, 2021. It is now read-only.

Commit 2aa1748

Browse files
authored
Require auth for creating gists (sigmavirus24#802)
Per https://blog.github.com/2018-02-18-deprecation-notice-removing-anonymous-gist-creation/ anonymous gist creation is no longer possible on GitHub. Also updates the betamax cassette to ensure tests still work against current API. Resolves: sigmavirus24#795
1 parent dcb72b3 commit 2aa1748

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

github3/github.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,17 @@ def check_authorization(self, access_token):
279279
return self._boolean(resp, 200, 404)
280280
return False
281281

282+
@requires_auth
282283
def create_gist(self, description, files, public=True):
283284
"""Create a new gist.
284285
285-
If no login was provided, it will be anonymous.
286+
.. versionchanged:: 1.1.0
287+
288+
Per `GitHub's recent announcement`_ authentication is now required
289+
for creating gists.
290+
291+
.. _GitHub's recent announcement:
292+
https://blog.github.com/2018-02-18-deprecation-notice-removing-anonymous-gist-creation/
286293
287294
:param str description:
288295
(required), description of gist
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"recorded_with": "betamax/0.8.0", "http_interactions": [{"response": {"body": {"string": "{\"url\":\"https://api.github.com/gists/9395aa23e0eabbb5a7e58a0166763579\",\"forks_url\":\"https://api.github.com/gists/9395aa23e0eabbb5a7e58a0166763579/forks\",\"commits_url\":\"https://api.github.com/gists/9395aa23e0eabbb5a7e58a0166763579/commits\",\"id\":\"9395aa23e0eabbb5a7e58a0166763579\",\"git_pull_url\":\"https://gist.github.com/9395aa23e0eabbb5a7e58a0166763579.git\",\"git_push_url\":\"https://gist.github.com/9395aa23e0eabbb5a7e58a0166763579.git\",\"html_url\":\"https://gist.github.com/9395aa23e0eabbb5a7e58a0166763579\",\"files\":{\"filename.py\":{\"filename\":\"filename.py\",\"type\":\"application/x-python\",\"language\":\"Python\",\"raw_url\":\"https://gist.githubusercontent.com/sigmavirus24/9395aa23e0eabbb5a7e58a0166763579/raw/dc60090e8af1ccb3fb2151390b56d02ca8c2623c/filename.py\",\"size\":8,\"truncated\":false,\"content\":\"#content\"}},\"public\":true,\"created_at\":\"2017-02-01T12:31:17Z\",\"updated_at\":\"2017-02-01T12:31:17Z\",\"description\":\"Gist Title\",\"comments\":0,\"user\":null,\"comments_url\":\"https://api.github.com/gists/9395aa23e0eabbb5a7e58a0166763579/comments\",\"owner\":{\"login\":\"sigmavirus24\",\"id\":240830,\"avatar_url\":\"https://avatars.githubusercontent.com/u/240830?v=3\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/sigmavirus24\",\"html_url\":\"https://github.com/sigmavirus24\",\"followers_url\":\"https://api.github.com/users/sigmavirus24/followers\",\"following_url\":\"https://api.github.com/users/sigmavirus24/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/sigmavirus24/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/sigmavirus24/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/sigmavirus24/subscriptions\",\"organizations_url\":\"https://api.github.com/users/sigmavirus24/orgs\",\"repos_url\":\"https://api.github.com/users/sigmavirus24/repos\",\"events_url\":\"https://api.github.com/users/sigmavirus24/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/sigmavirus24/received_events\",\"type\":\"User\",\"site_admin\":false},\"forks\":[],\"history\":[{\"user\":{\"login\":\"sigmavirus24\",\"id\":240830,\"avatar_url\":\"https://avatars.githubusercontent.com/u/240830?v=3\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/sigmavirus24\",\"html_url\":\"https://github.com/sigmavirus24\",\"followers_url\":\"https://api.github.com/users/sigmavirus24/followers\",\"following_url\":\"https://api.github.com/users/sigmavirus24/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/sigmavirus24/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/sigmavirus24/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/sigmavirus24/subscriptions\",\"organizations_url\":\"https://api.github.com/users/sigmavirus24/orgs\",\"repos_url\":\"https://api.github.com/users/sigmavirus24/repos\",\"events_url\":\"https://api.github.com/users/sigmavirus24/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/sigmavirus24/received_events\",\"type\":\"User\",\"site_admin\":false},\"version\":\"ac179de139603097d96e0a3fab20a67e7181eec1\",\"committed_at\":\"2017-02-01T12:31:17Z\",\"change_status\":{\"total\":1,\"additions\":1,\"deletions\":0},\"url\":\"https://api.github.com/gists/9395aa23e0eabbb5a7e58a0166763579/ac179de139603097d96e0a3fab20a67e7181eec1\"}],\"truncated\":false}", "encoding": "utf-8"}, "url": "https://api.github.com/gists", "status": {"code": 201, "message": "Created"}, "headers": {"Content-Type": "application/json; charset=utf-8", "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "X-RateLimit-Reset": "1485953436", "Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "Server": "GitHub.com", "Location": "https://api.github.com/gists/9395aa23e0eabbb5a7e58a0166763579", "Content-Length": "3184", "ETag": "\"8fb72f95b0ea3d24f02f024a7a5f4f65\"", "X-GitHub-Media-Type": "github.v3; param=full; format=json", "Cache-Control": "private, max-age=60, s-maxage=60", "Access-Control-Allow-Origin": "*", "X-GitHub-Request-Id": "8CA3:2C93:5BBB3AB:747BAA9:5891D515", "X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user", "Status": "201 Created", "X-Frame-Options": "deny", "Content-Security-Policy": "default-src 'none'", "X-RateLimit-Remaining": "4992", "X-Content-Type-Options": "nosniff", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "X-Accepted-OAuth-Scopes": "", "X-Served-By": "d256f86292c6dde5d09d15d926ec67a3", "X-XSS-Protection": "1; mode=block", "Date": "Wed, 01 Feb 2017 12:31:17 GMT", "X-RateLimit-Limit": "5000"}}, "recorded_at": "2017-02-01T12:31:17", "request": {"method": "POST", "uri": "https://api.github.com/gists", "body": {"string": "{\"files\": {\"filename.py\": {\"content\": \"#content\"}}, \"public\": true, \"description\": \"Gist Title\"}", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Content-Type": "application/json", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Accept": "application/vnd.github.v3.full+json", "Content-Length": "96", "Authorization": "token <AUTH_TOKEN>", "User-Agent": "github3.py/1.0.0a4"}}}]}
1+
{"http_interactions": [{"request": {"body": {"encoding": "utf-8", "string": "{\"description\": \"Gist Title\", \"public\": true, \"files\": {\"filename.py\": {\"content\": \"#content\"}}}"}, "headers": {"User-Agent": ["github3.py/1.0.1"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["application/vnd.github.v3.full+json"], "Connection": ["keep-alive"], "Accept-Charset": ["utf-8"], "Content-Type": ["application/json"], "Authorization": ["token <AUTH_TOKEN>"], "Content-Length": ["96"]}, "method": "POST", "uri": "https://api.github.com/gists"}, "response": {"body": {"encoding": "utf-8", "string": "{\"url\":\"https://api.github.com/gists/6619e8351887b03f6c821e1f715d1de8\",\"forks_url\":\"https://api.github.com/gists/6619e8351887b03f6c821e1f715d1de8/forks\",\"commits_url\":\"https://api.github.com/gists/6619e8351887b03f6c821e1f715d1de8/commits\",\"id\":\"6619e8351887b03f6c821e1f715d1de8\",\"git_pull_url\":\"https://gist.github.com/6619e8351887b03f6c821e1f715d1de8.git\",\"git_push_url\":\"https://gist.github.com/6619e8351887b03f6c821e1f715d1de8.git\",\"html_url\":\"https://gist.github.com/6619e8351887b03f6c821e1f715d1de8\",\"files\":{\"filename.py\":{\"filename\":\"filename.py\",\"type\":\"application/x-python\",\"language\":\"Python\",\"raw_url\":\"https://gist.githubusercontent.com/omgjlk/6619e8351887b03f6c821e1f715d1de8/raw/dc60090e8af1ccb3fb2151390b56d02ca8c2623c/filename.py\",\"size\":8,\"truncated\":false,\"content\":\"#content\"}},\"public\":true,\"created_at\":\"2018-03-21T00:08:25Z\",\"updated_at\":\"2018-03-21T00:08:25Z\",\"description\":\"Gist Title\",\"comments\":0,\"user\":null,\"comments_url\":\"https://api.github.com/gists/6619e8351887b03f6c821e1f715d1de8/comments\",\"owner\":{\"login\":\"omgjlk\",\"id\":523287,\"avatar_url\":\"https://avatars2.githubusercontent.com/u/523287?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/omgjlk\",\"html_url\":\"https://github.com/omgjlk\",\"followers_url\":\"https://api.github.com/users/omgjlk/followers\",\"following_url\":\"https://api.github.com/users/omgjlk/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/omgjlk/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/omgjlk/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/omgjlk/subscriptions\",\"organizations_url\":\"https://api.github.com/users/omgjlk/orgs\",\"repos_url\":\"https://api.github.com/users/omgjlk/repos\",\"events_url\":\"https://api.github.com/users/omgjlk/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/omgjlk/received_events\",\"type\":\"User\",\"site_admin\":true},\"forks\":[],\"history\":[{\"user\":{\"login\":\"omgjlk\",\"id\":523287,\"avatar_url\":\"https://avatars2.githubusercontent.com/u/523287?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/omgjlk\",\"html_url\":\"https://github.com/omgjlk\",\"followers_url\":\"https://api.github.com/users/omgjlk/followers\",\"following_url\":\"https://api.github.com/users/omgjlk/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/omgjlk/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/omgjlk/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/omgjlk/subscriptions\",\"organizations_url\":\"https://api.github.com/users/omgjlk/orgs\",\"repos_url\":\"https://api.github.com/users/omgjlk/repos\",\"events_url\":\"https://api.github.com/users/omgjlk/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/omgjlk/received_events\",\"type\":\"User\",\"site_admin\":true},\"version\":\"015504852a9d751e7b953c696364f5daa6178e84\",\"committed_at\":\"2018-03-21T00:08:25Z\",\"change_status\":{\"total\":1,\"additions\":1,\"deletions\":0},\"url\":\"https://api.github.com/gists/6619e8351887b03f6c821e1f715d1de8/015504852a9d751e7b953c696364f5daa6178e84\"}],\"truncated\":false}"}, "headers": {"Date": ["Wed, 21 Mar 2018 00:08:26 GMT"], "Content-Type": ["application/json; charset=utf-8"], "Content-Length": ["3034"], "Server": ["GitHub.com"], "Status": ["201 Created"], "X-RateLimit-Limit": ["5000"], "X-RateLimit-Remaining": ["4980"], "X-RateLimit-Reset": ["1521593187"], "Cache-Control": ["private, max-age=60, s-maxage=60"], "Vary": ["Accept, Authorization, Cookie, X-GitHub-OTP", "Accept-Encoding"], "ETag": ["\"4ec6db85d7b32481e0aa916a2d32d1aa\""], "X-OAuth-Scopes": ["gist, repo"], "X-Accepted-OAuth-Scopes": [""], "Location": ["https://api.github.com/gists/6619e8351887b03f6c821e1f715d1de8"], "X-GitHub-Media-Type": ["github.v3; param=full; format=json"], "Access-Control-Expose-Headers": ["ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval"], "Access-Control-Allow-Origin": ["*"], "Strict-Transport-Security": ["max-age=31536000; includeSubdomains; preload"], "X-Frame-Options": ["deny"], "X-Content-Type-Options": ["nosniff"], "X-XSS-Protection": ["1; mode=block"], "Referrer-Policy": ["origin-when-cross-origin, strict-origin-when-cross-origin"], "Content-Security-Policy": ["default-src 'none'"], "X-Runtime-rack": ["1.157239"], "X-GitHub-Request-Id": ["F00A:471D:AD4E9F:DBE840:5AB1A278"]}, "status": {"code": 201, "message": "Created"}, "url": "https://api.github.com/gists"}, "recorded_at": "2018-03-21T00:08:26"}], "recorded_with": "betamax/0.8.1"}

0 commit comments

Comments
 (0)
0