Skip to content

Commit f7c29a1

Browse files
added Authorization header if access_token exists
1 parent 3fe8143 commit f7c29a1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

binderhub/repoproviders.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,13 +435,13 @@ def _access_token_default(self):
435435
auth = Dict(
436436
help="""Auth parameters for the GitHub API access
437437
438-
Populated from client_id, client_secret, access_token.
438+
Populated from client_id, client_secret.
439439
"""
440440
)
441441
@default('auth')
442442
def _default_auth(self):
443443
auth = {}
444-
for key in ('client_id', 'client_secret', 'access_token'):
444+
for key in ('client_id', 'client_secret'):
445445
value = getattr(self, key)
446446
if value:
447447
auth[key] = value
@@ -477,6 +477,10 @@ def github_api_request(self, api_url, etag=None):
477477
api_url = url_concat(api_url, self.auth)
478478

479479
headers = {}
480+
# based on: https://developer.github.com/v3/#oauth2-token-sent-in-a-header
481+
if self.access_token:
482+
headers['Authorization'] = "token {token}".format(token=self.access_token)
483+
480484
if etag:
481485
headers['If-None-Match'] = etag
482486
req = HTTPRequest(api_url, headers=headers, user_agent="BinderHub")

0 commit comments

Comments
 (0)