Skip to content

Commit 99af80d

Browse files
authored
added Authorization header if access_token provided (#954)
added Authorization header if access_token provided
2 parents 07b71cd + e3858f9 commit 99af80d

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
@@ -436,13 +436,13 @@ def _access_token_default(self):
436436
auth = Dict(
437437
help="""Auth parameters for the GitHub API access
438438
439-
Populated from client_id, client_secret, access_token.
439+
Populated from client_id, client_secret.
440440
"""
441441
)
442442
@default('auth')
443443
def _default_auth(self):
444444
auth = {}
445-
for key in ('client_id', 'client_secret', 'access_token'):
445+
for key in ('client_id', 'client_secret'):
446446
value = getattr(self, key)
447447
if value:
448448
auth[key] = value
@@ -478,6 +478,10 @@ def github_api_request(self, api_url, etag=None):
478478
api_url = url_concat(api_url, self.auth)
479479

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

0 commit comments

Comments
 (0)