class documentation

A receiver that reads a token from a filesystem path.

Calls to _fetch return the bearer's cached token when it is still fresh; otherwise the configured file is opened and read. When authentication fails, can_retry invalidates the cache and retries only if the token file changed.

Parameters
filepathlib.Path pointing to a file containing a raw access token (UTF-8 text). The file is read on each fetch and must contain a non-empty token string.
Method __init__ Create a file-backed receiver.
Method can_retry Retry only when the token file changed after the last fetch.
Async Method _fetch Read the token file and return a Token.
Instance Variable _bearer Undocumented

Inherited from Receiver:

Async Method fetch Fetch a token and record it as the latest value.
Property latest Return the latest fetched token or None.
Instance Variable _latest The most recently fetched token, or None if no token has been fetched yet. Implementations may update this to support inspection or caching by callers.
def __init__(self, bearer: Bearer): (source)

Create a file-backed receiver.

def can_retry(self, err: Exception, options: dict[str, str] | None = None) -> bool: (source)

Retry only when the token file changed after the last fetch.

Authentication failures may be caused by an external process rotating the token file. The bearer clears its cache and compares current file contents with the token used by this receiver. If they differ, the request layer may authenticate again and pick up the new token.

async def _fetch(self, timeout: float | None = None, options: dict[str, str] | None = None) -> Token: (source)

Read the token file and return a Token.

Parameters
timeout:float | NoneIgnored for file-backed receivers but accepted for API compatibility.
options:dict[str, str] | NoneIgnored; present for API compatibility.
Returns
TokenA Token constructed from the file contents.
Raises
SDKErrorIf the file contains an empty string.
OSErrorIf the file cannot be opened.

Undocumented