Skip to content

Commit

Permalink
ARROW-218: Add optional API token authentication option to PR merge tool
Browse files Browse the repository at this point in the history
You can use an API token with extremely limited privileges (i.e., only access to public GitHub repos), but this helps avoid rate limiting issues on shared outbound IP addresses.

Author: Wes McKinney <wesm@apache.org>

Closes #91 from wesm/ARROW-218 and squashes the following commits:

f45808c [Wes McKinney] Add optional GitHub API token to patch tool (to avoid rate limiting issues with unauthenticated requests)
  • Loading branch information
wesm committed Jun 16, 2016
1 parent b4e0e93 commit 790d541
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion dev/merge_arrow_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,17 @@

def get_json(url):
try:
return json.load(urllib2.urlopen(url))
from urllib2 import urlopen, Request
env_var = 'ARROW_GITHUB_API_TOKEN'

if env_var in os.environ:
token = os.environ[env_var]
request = Request(url)
request.add_header('Authorization', 'token %s' % token)
response = urlopen(request)
else:
response = urlopen(url)
return json.load(response)
except urllib2.HTTPError as e:
print "Unable to fetch URL, exiting: %s" % url
sys.exit(-1)
Expand Down

0 comments on commit 790d541

Please sign in to comment.