mirror of
https://github.com/hanzoai/apple-health-mcp-server.git
synced 2026-10-30 18:47:42 +00:00
16 lines
504 B
Python
16 lines
504 B
Python
from requests import PreparedRequest
|
|
from requests.structures import CaseInsensitiveDict
|
|
from requests.auth import AuthBase
|
|
|
|
|
|
class BearerAuth(AuthBase):
|
|
"""Attaches HTTP Bearer Authentication to the given Request object."""
|
|
|
|
def __init__(self, token: str):
|
|
self.token = token
|
|
|
|
def __call__(self, r: PreparedRequest) -> PreparedRequest:
|
|
r.headers = r.headers or CaseInsensitiveDict()
|
|
r.headers["Authorization"] = f"Bearer {self.token}"
|
|
return r
|