8000 Require auth for creating gists by omgjlk · Pull Request #802 · sigmavirus24/github3.py · GitHub
[go: up one dir, main page]

Skip to content

Require auth for creating gists #802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion github3/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,17 @@ def check_authorization(self, access_token):
return self._boolean(resp, 200, 404)
return False

@requires_auth
def create_gist(self, description, files, public=True):
"""Create a new gist.

If no login was provided, it will be anonymous.
.. versionchanged:: 1.1.0

Per `GitHub's recent announcement`_ authentication is now required
for creating gists.

.. _GitHub's recent announcement:
https://blog.github.com/2018-02-18-deprecation-notice-removing-anonymous-gist-creation/

:param str description:
(required), description of gist
Expand Down
2 changes: 1 addition & 1 deletion tests/cassettes/GitHub_create_gist.json
Original file line number Diff line number Diff line change
@@ -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"}}}]}
{"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