forked from Kinto/kinto-http.py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
47 lines (37 loc) · 1019 Bytes
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import logging
import requests
from kinto_http.client import AsyncClient, Client
from kinto_http.endpoints import Endpoints
from kinto_http.exceptions import (
BucketNotFound,
CollectionNotFound,
KintoBatchException,
KintoException,
)
from kinto_http.login import BrowserOAuth
from kinto_http.session import Session, create_session
logger = logging.getLogger("kinto_http")
__all__ = (
"BrowserOAuth",
"TokenAuth",
"BearerTokenAuth",
"Endpoints",
"Session",
"AsyncClient",
"Client",
"create_session",
"BucketNotFound",
"CollectionNotFound",
"KintoException",
"KintoBatchException",
)
class TokenAuth(requests.auth.AuthBase):
def __init__(self, token, type=None):
self.token = token
self.type = type or "Bearer"
def __call__(self, r):
# Sets auth-scheme to either Bearer or Basic
r.headers["Authorization"] = "{} {}".format(self.type, self.token)
return r
class BearerTokenAuth(TokenAuth):
pass