diff --git a/binderhub/repoproviders.py b/binderhub/repoproviders.py index 7ddcc6a8e..d53dbdfb0 100644 --- a/binderhub/repoproviders.py +++ b/binderhub/repoproviders.py @@ -435,13 +435,13 @@ def _access_token_default(self): auth = Dict( help="""Auth parameters for the GitHub API access - Populated from client_id, client_secret, access_token. + Populated from client_id, client_secret. """ ) @default('auth') def _default_auth(self): auth = {} - for key in ('client_id', 'client_secret', 'access_token'): + for key in ('client_id', 'client_secret'): value = getattr(self, key) if value: auth[key] = value @@ -477,6 +477,10 @@ def github_api_request(self, api_url, etag=None): api_url = url_concat(api_url, self.auth) headers = {} + # based on: https://developer.github.com/v3/#oauth2-token-sent-in-a-header + if self.access_token: + headers['Authorization'] = "token {token}".format(token=self.access_token) + if etag: headers['If-None-Match'] = etag req = HTTPRequest(api_url, headers=headers, user_agent="BinderHub")