File: requests.py

package info (click to toggle)
python-caldav 1.3.9-1.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 640 kB
  • sloc: python: 6,824; makefile: 91; sh: 7
file content (16 lines) | stat: -rw-r--r-- 402 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from requests.auth import AuthBase


class HTTPBearerAuth(AuthBase):
    def __init__(self, password):
        self.password = password

    def __eq__(self, other):
        return self.password == getattr(other, "password", None)

    def __ne__(self, other):
        return not self == other

    def __call__(self, r):
        r.headers["Authorization"] = f"Bearer {self.password}"
        return r