Skip to content

Commit

Permalink
fix: make BearerAuth's token_getter public
Browse files Browse the repository at this point in the history
  • Loading branch information
derlin committed Mar 21, 2024
1 parent 33603fb commit b94f33c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mantelo/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import requests
import slumber
from attrs import define
from slumber.exceptions import SlumberHttpBaseException

from .connection import (
Expand All @@ -27,12 +28,12 @@ def _request(self, *args, **kwargs):
raise HttpException.from_slumber_exception(ex) from None


@define
class BearerAuth(requests.auth.AuthBase):
def __init__(self, token_getter: Callable[[], str]):
self._token_getter = token_getter
token_getter: Callable[[], str]

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


Expand Down

0 comments on commit b94f33c

Please sign in to comment.