{"action":"created","comment":{"url":"https://api.github.com/repos/google/oauth2client/pulls/comments/66476693","id":66476693,"diff_hunk":"@@ -0,0 +1,93 @@\n+# Copyright 2016 Google Inc. All rights reserved.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+#      http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+\n+\"\"\"Thin wrapper class for talking to the GCE Metadata Server.\"\"\"\n+import datetime\n+import httplib2\n+import json\n+\n+from six.moves import http_client\n+\n+from oauth2client._helpers import _from_bytes\n+from oauth2client.client import _UTCNOW\n+from oauth2client.client import HttpAccessTokenRefreshError\n+\n+METADATA_ROOT = 'http://metadata.google.internal/computeMetadata/v1/'\n+METADATA_HEADERS = {'Metadata-Flavor': 'Google'}\n+\n+\n+def get(path, recursive=True, http_request=None, root=METADATA_ROOT):\n+    if path is None:\n+        path = []\n+\n+    if not http_request:\n+        http_request = httplib2.Http().request\n+\n+    r_string = '/?recursive=true' if recursive else ''\n+    full_path = root + '/'.join(path) + r_string\n+    response, content = http_request(\n+        full_path,\n+        headers=METADATA_HEADERS\n+    )\n+    if response.status == http_client.OK:\n+        decoded = _from_bytes(content)\n+        if response['content-type'] == 'application/json':\n+            return json.loads(decoded)\n+        else:\n+            return decoded\n+    else:\n+        msg = (\n+            'Failed to retrieve {path} from the Google Compute Engine'\n+            'metadata service. Response:\\n{error}'\n+        ).format(path=full_path, error=response)\n+        raise httplib2.HttpLib2Error(msg)\n+\n+\n+def get_service_account_info(service_account='default', http_request=None):\n+    \"\"\" Get information about a service account from the metadata server.","path":"oauth2client/contrib/metadata.py","position":58,"original_position":58,"commit_id":"893c0e47c8a47f340993432949f81997157129b9","original_commit_id":"893c0e47c8a47f340993432949f81997157129b9","user":{"login":"jonparrott","id":250995,"avatar_url":"https://avatars.githubusercontent.com/u/250995?v=3","gravatar_id":"","url":"https://api.github.com/users/jonparrott","html_url":"https://github.com/jonparrott","followers_url":"https://api.github.com/users/jonparrott/followers","following_url":"https://api.github.com/users/jonparrott/following{/other_user}","gists_url":"https://api.github.com/users/jonparrott/gists{/gist_id}","starred_url":"https://api.github.com/users/jonparrott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonparrott/subscriptions","organizations_url":"https://api.github.com/users/jonparrott/orgs","repos_url":"https://api.github.com/users/jonparrott/repos","events_url":"https://api.github.com/users/jonparrott/events{/privacy}","received_events_url":"https://api.github.com/users/jonparrott/received_events","type":"User","site_admin":false},"body":"These doc strings should be in the same format as `flask-util`'s:\r\n\r\n```python\r\n   def _load_config(self, client_secrets_file, client_id, client_secret):\r\n        \"\"\"Loads oauth2 configuration in order of priority.\r\n\r\n        Priority:\r\n            1. Config passed to the constructor or init_app.\r\n            2. Config passed via the GOOGLE_OAUTH2_CLIENT_SECRETS_FILE app\r\n               config.\r\n            3. Config passed via the GOOGLE_OAUTH2_CLIENT_ID and\r\n               GOOGLE_OAUTH2_CLIENT_SECRET app config.\r\n\r\n        Raises:\r\n            ValueError if no config could be found.\r\n        \"\"\"\r\n```","created_at":"2016-06-09T16:40:16Z","updated_at":"2016-06-09T16:40:16Z","html_url":"https://github.com/google/oauth2client/pull/520#discussion_r66476693","pull_request_url":"https://api.github.com/repos/google/oauth2client/pulls/520","_links":{"self":{"href":"https://api.github.com/repos/google/oauth2client/pulls/comments/66476693"},"html":{"href":"https://github.com/google/oauth2client/pull/520#discussion_r66476693"},"pull_request":{"href":"https://api.github.com/repos/google/oauth2client/pulls/520"}}},"pull_request":{"url":"https://api.github.com/repos/google/oauth2client/pulls/520","id":73112886,"html_url":"https://github.com/google/oauth2client/pull/520","diff_url":"https://github.com/google/oauth2client/pull/520.diff","patch_url":"https://github.com/google/oauth2client/pull/520.patch","issue_url":"https://api.github.com/repos/google/oauth2client/issues/520","number":520,"state":"open","locked":false,"title":"Factor metadata interface into a separate module","user":{"login":"elibixby","id":6596957,"avatar_url":"https://avatars.githubusercontent.com/u/6596957?v=3","gravatar_id":"","url":"https://api.github.com/users/elibixby","html_url":"https://github.com/elibixby","followers_url":"https://api.github.com/users/elibixby/followers","following_url":"https://api.github.com/users/elibixby/following{/other_user}","gists_url":"https://api.github.com/users/elibixby/gists{/gist_id}","starred_url":"https://api.github.com/users/elibixby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elibixby/subscriptions","organizations_url":"https://api.github.com/users/elibixby/orgs","repos_url":"https://api.github.com/users/elibixby/repos","events_url":"https://api.github.com/users/elibixby/events{/privacy}","received_events_url":"https://api.github.com/users/elibixby/received_events","type":"User","site_admin":false},"body":"First in a series of PRs which are loosely based on #476 \r\n\r\nRealized that Metadata Server interaction should be decoupled from GCE App Assertion Credentials. `gce.AppAssertionCredentials`. ","created_at":"2016-06-08T20:17:00Z","updated_at":"2016-06-09T16:40:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0bc8c185e9cd35da01b8c863223fdf0360593c8a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/google/oauth2client/pulls/520/commits","review_comments_url":"https://api.github.com/repos/google/oauth2client/pulls/520/comments","review_comment_url":"https://api.github.com/repos/google/oauth2client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/oauth2client/issues/520/comments","statuses_url":"https://api.github.com/repos/google/oauth2client/statuses/893c0e47c8a47f340993432949f81997157129b9","head":{"label":"elibixby:metadata","ref":"metadata","sha":"893c0e47c8a47f340993432949f81997157129b9","user":{"login":"elibixby","id":6596957,"avatar_url":"https://avatars.githubusercontent.com/u/6596957?v=3","gravatar_id":"","url":"https://api.github.com/users/elibixby","html_url":"https://github.com/elibixby","followers_url":"https://api.github.com/users/elibixby/followers","following_url":"https://api.github.com/users/elibixby/following{/other_user}","gists_url":"https://api.github.com/users/elibixby/gists{/gist_id}","starred_url":"https://api.github.com/users/elibixby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elibixby/subscriptions","organizations_url":"https://api.github.com/users/elibixby/orgs","repos_url":"https://api.github.com/users/elibixby/repos","events_url":"https://api.github.com/users/elibixby/events{/privacy}","received_events_url":"https://api.github.com/users/elibixby/received_events","type":"User","site_admin":false},"repo":{"id":50957874,"name":"oauth2client","full_name":"elibixby/oauth2client","owner":{"login":"elibixby","id":6596957,"avatar_url":"https://avatars.githubusercontent.com/u/6596957?v=3","gravatar_id":"","url":"https://api.github.com/users/elibixby","html_url":"https://github.com/elibixby","followers_url":"https://api.github.com/users/elibixby/followers","following_url":"https://api.github.com/users/elibixby/following{/other_user}","gists_url":"https://api.github.com/users/elibixby/gists{/gist_id}","starred_url":"https://api.github.com/users/elibixby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elibixby/subscriptions","organizations_url":"https://api.github.com/users/elibixby/orgs","repos_url":"https://api.github.com/users/elibixby/repos","events_url":"https://api.github.com/users/elibixby/events{/privacy}","received_events_url":"https://api.github.com/users/elibixby/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/elibixby/oauth2client","description":"This is a Python library for accessing resources protected by OAuth 2.0.","fork":true,"url":"https://api.github.com/repos/elibixby/oauth2client","forks_url":"https://api.github.com/repos/elibixby/oauth2client/forks","keys_url":"https://api.github.com/repos/elibixby/oauth2client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elibixby/oauth2client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elibixby/oauth2client/teams","hooks_url":"https://api.github.com/repos/elibixby/oauth2client/hooks","issue_events_url":"https://api.github.com/repos/elibixby/oauth2client/issues/events{/number}","events_url":"https://api.github.com/repos/elibixby/oauth2client/events","assignees_url":"https://api.github.com/repos/elibixby/oauth2client/assignees{/user}","branches_url":"https://api.github.com/repos/elibixby/oauth2client/branches{/branch}","tags_url":"https://api.github.com/repos/elibixby/oauth2client/tags","blobs_url":"https://api.github.com/repos/elibixby/oauth2client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elibixby/oauth2client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elibixby/oauth2client/git/refs{/sha}","trees_url":"https://api.github.com/repos/elibixby/oauth2client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elibixby/oauth2client/statuses/{sha}","languages_url":"https://api.github.com/repos/elibixby/oauth2client/languages","stargazers_url":"https://api.github.com/repos/elibixby/oauth2client/stargazers","contributors_url":"https://api.github.com/repos/elibixby/oauth2client/contributors","subscribers_url":"https://api.github.com/repos/elibixby/oauth2client/subscribers","subscription_url":"https://api.github.com/repos/elibixby/oauth2client/subscription","commits_url":"https://api.github.com/repos/elibixby/oauth2client/commits{/sha}","git_commits_url":"https://api.github.com/repos/elibixby/oauth2client/git/commits{/sha}","comments_url":"https://api.github.com/repos/elibixby/oauth2client/comments{/number}","issue_comment_url":"https://api.github.com/repos/elibixby/oauth2client/issues/comments{/number}","contents_url":"https://api.github.com/repos/elibixby/oauth2client/contents/{+path}","compare_url":"https://api.github.com/repos/elibixby/oauth2client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elibixby/oauth2client/merges","archive_url":"https://api.github.com/repos/elibixby/oauth2client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elibixby/oauth2client/downloads","issues_url":"https://api.github.com/repos/elibixby/oauth2client/issues{/number}","pulls_url":"https://api.github.com/repos/elibixby/oauth2client/pulls{/number}","milestones_url":"https://api.github.com/repos/elibixby/oauth2client/milestones{/number}","notifications_url":"https://api.github.com/repos/elibixby/oauth2client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elibixby/oauth2client/labels{/name}","releases_url":"https://api.github.com/repos/elibixby/oauth2client/releases{/id}","deployments_url":"https://api.github.com/repos/elibixby/oauth2client/deployments","created_at":"2016-02-02T22:54:18Z","updated_at":"2016-02-02T22:54:19Z","pushed_at":"2016-06-09T00:46:18Z","git_url":"git://github.com/elibixby/oauth2client.git","ssh_url":"git@github.com:elibixby/oauth2client.git","clone_url":"https://github.com/elibixby/oauth2client.git","svn_url":"https://github.com/elibixby/oauth2client","homepage":"","size":23646,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"c4e17ec922120fb68bd6621ad7c31e09bd699cc5","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":14211461,"name":"oauth2client","full_name":"google/oauth2client","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/oauth2client","description":"This is a Python library for accessing resources protected by OAuth 2.0.","fork":false,"url":"https://api.github.com/repos/google/oauth2client","forks_url":"https://api.github.com/repos/google/oauth2client/forks","keys_url":"https://api.github.com/repos/google/oauth2client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/oauth2client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/oauth2client/teams","hooks_url":"https://api.github.com/repos/google/oauth2client/hooks","issue_events_url":"https://api.github.com/repos/google/oauth2client/issues/events{/number}","events_url":"https://api.github.com/repos/google/oauth2client/events","assignees_url":"https://api.github.com/repos/google/oauth2client/assignees{/user}","branches_url":"https://api.github.com/repos/google/oauth2client/branches{/branch}","tags_url":"https://api.github.com/repos/google/oauth2client/tags","blobs_url":"https://api.github.com/repos/google/oauth2client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/oauth2client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/oauth2client/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/oauth2client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/oauth2client/statuses/{sha}","languages_url":"https://api.github.com/repos/google/oauth2client/languages","stargazers_url":"https://api.github.com/repos/google/oauth2client/stargazers","contributors_url":"https://api.github.com/repos/google/oauth2client/contributors","subscribers_url":"https://api.github.com/repos/google/oauth2client/subscribers","subscription_url":"https://api.github.com/repos/google/oauth2client/subscription","commits_url":"https://api.github.com/repos/google/oauth2client/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/oauth2client/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/oauth2client/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/oauth2client/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/oauth2client/contents/{+path}","compare_url":"https://api.github.com/repos/google/oauth2client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/oauth2client/merges","archive_url":"https://api.github.com/repos/google/oauth2client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/oauth2client/downloads","issues_url":"https://api.github.com/repos/google/oauth2client/issues{/number}","pulls_url":"https://api.github.com/repos/google/oauth2client/pulls{/number}","milestones_url":"https://api.github.com/repos/google/oauth2client/milestones{/number}","notifications_url":"https://api.github.com/repos/google/oauth2client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/oauth2client/labels{/name}","releases_url":"https://api.github.com/repos/google/oauth2client/releases{/id}","deployments_url":"https://api.github.com/repos/google/oauth2client/deployments","created_at":"2013-11-07T18:03:04Z","updated_at":"2016-06-07T00:11:18Z","pushed_at":"2016-06-08T23:39:53Z","git_url":"git://github.com/google/oauth2client.git","ssh_url":"git@github.com:google/oauth2client.git","clone_url":"https://github.com/google/oauth2client.git","svn_url":"https://github.com/google/oauth2client","homepage":"","size":24516,"stargazers_count":378,"watchers_count":378,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":198,"mirror_url":null,"open_issues_count":92,"forks":198,"open_issues":92,"watchers":378,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/oauth2client/pulls/520"},"html":{"href":"https://github.com/google/oauth2client/pull/520"},"issue":{"href":"https://api.github.com/repos/google/oauth2client/issues/520"},"comments":{"href":"https://api.github.com/repos/google/oauth2client/issues/520/comments"},"review_comments":{"href":"https://api.github.com/repos/google/oauth2client/pulls/520/comments"},"review_comment":{"href":"https://api.github.com/repos/google/oauth2client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/oauth2client/pulls/520/commits"},"statuses":{"href":"https://api.github.com/repos/google/oauth2client/statuses/893c0e47c8a47f340993432949f81997157129b9"}}}}
{"actor":{"display_login":"jonparrott"}}