-
-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Description
We used to authenticate using:
auth_token = subprocess.check_output(['heroku', 'auth:token'])
heroku = heroku3.from_key(auth_token)
This started failing recently (maybe a month ago?). Digging in, it seems like Heroku only supports a Bearer <Token> Authorization header (https://devcenter.heroku.com/articles/platform-api-quickstart#authentication). I don't see any reference to a Basic Authorization header - My best guess is that it was supported, but has been deprecated?
I was able to work around this and successfully authenticate with the following bit of code:
class BearerAuth(requests.auth.AuthBase):
""" Token based authentication """
def __init__(self, token):
self.token = token
def __eq__(self, other):
return self.token == getattr(other, 'token', None)
def __ne__(self, other):
return not self == other
def __call__(self, r):
r.headers['Authorization'] = 'Bearer %s' % self.token
return r
class Heroku31(heroku3.api.Heroku):
""" Monkey patched Heroku3 - Heroku doesn't accept Basic Auth anymore """
def authenticate(self, api_key):
"""Logs user into Heroku with given api_key."""
self._api_key = api_key
# Attach auth to session.
self._session.auth = BearerAuth(self._api_key)
return self._verify_api_key()
I'm kind of surprised nobody else has run into this - so, maybe we were just doing something wrong from the start?
Metadata
Metadata
Assignees
Labels
No labels