blob: 9de2a8c4b0776a89e97d45de8cc16a42060e5b82 [file] [log] [blame]
Akronca9bd982016-12-06 16:59:57 +01001from requests.auth import AuthBase
2
3__author__ = 'hanl'
4
5
6class Oauth2Auth(AuthBase):
7 '''
8 starts needs to match the provider name
9 '''
10 def __init__(self, token=None):
11 self.token = token
12
13 def __call__(self, r):
14 if self.token is not None:
15 r.headers['Authorization'] = "OAuth2 Bearer " + self.token
16 return r
17
18
19class CustomAuth(AuthBase):
20 def __init__(self, token=None):
21 self.token = token
22
23 def __call__(self, r):
24 if self.token is not None:
25 r.headers['Authorization'] = "api_token " + self.token
26 return r