redditwarp.core.authorizer_SYNC
#
- class redditwarp.core.authorizer_SYNC.Authorizer(token_client: TokenObtainmentClient | None = None, token: Token | None = None)[source]#
Bases:
object
An object for managing the token.
The
Authorizer
keeps token information and knows how to renew the token when it expires and how to prepare a requisition.- token_client: TokenObtainmentClient | None#
A token obtainment client used to make the token obtainment requests.
- token: Token | None#
Holds the current token information.
- renewal_skew: float#
Number of seconds before the token expiration when the token should be renewed.
- expires_in_fallback: int | None#
A fallback value for the token expiration time when not specified by the server.
- time_func: Callable[[], float]#
A function that returns the current time. The
time()
method calls this this function.
- authorization_header_name: str#
Name of the
Authorization
header. Use this attribute to change its capitalization.
- fetch_token_client() → TokenObtainmentClient[source]#
Return
.token_client
. RaiseRuntimeError
if not set.
- renew_token() → None[source]#
Renew the token.
- Raises:
RuntimeError – No token client (
token_client
) is set.
- time() → float[source]#
Return the current internal time. This is used for
renewal_time
.
- should_renew_token() → bool[source]#
Return true if the token is expired, about to expire, or is unset.
- can_renew_token() → bool[source]#
The token can be renewed if a token client (
token_client
) is available.
- prepare_requisition(requisition: Requisition) → None[source]#
Prepare a requisition for authorization using the token.
- class redditwarp.core.authorizer_SYNC.Authorized(handler: Handler, authorizer: Authorizer)[source]#
Bases:
DelegatingHandler
Used to make requests to endpoints that require authorization.
- authorizer: Authorizer#