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 | |
| file | pathlib.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 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. |
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)
¶
overrides
nebius.aio.token.token.Receiver._fetchRead the token file and return a Token.
| Parameters | |
timeout:float | None | Ignored for file-backed receivers but accepted for API compatibility. |
options:dict[ | Ignored; present for API compatibility. |
| Returns | |
Token | A Token constructed from the file contents. |
| Raises | |
SDKError | If the file contains an empty string. |
OSError | If the file cannot be opened. |