from requests.auth import AuthBase | |
__author__ = 'hanl' | |
class Oauth2Auth(AuthBase): | |
''' | |
starts needs to match the provider name | |
''' | |
def __init__(self, token=None): | |
self.token = token | |
def __call__(self, r): | |
if self.token is not None: | |
r.headers['Authorization'] = "OAuth2 Bearer " + self.token | |
return r | |
class CustomAuth(AuthBase): | |
def __init__(self, token=None): | |
self.token = token | |
def __call__(self, r): | |
if self.token is not None: | |
r.headers['Authorization'] = "api_token " + self.token | |
return r |