fresh_grpc library

Classes

FreshGrpc<T>
A Grpc Authenticator for automatic token refresh. Requires a concrete implementation of TokenStorage, ObtainToken and RefreshToken. Handles transparently refreshing/caching tokens.
InMemoryTokenStorage<T>
A TokenStorage implementation that keeps the token in memory.
OAuth2Token
Standard OAuth2Token as defined by https://www.oauth.com/oauth2-servers/access-tokens/access-token-response/
TokenStorage<T>
An interface which must be implemented to read, write, and delete the Token.

Enums

AuthenticationStatus
Enum representing the current authentication status of the application.

Mixins

FreshMixin<T>
A mixin which handles core token refresh functionality.

Functions

retryUnary<R, Q>(ResponseFuture<R> rpc(Q request, {CallOptions? options}), Q request, {dynamic onRetry(Exception)?, Duration delayFactor = const Duration(milliseconds: 200), double randomizationFactor = 0.25, Duration maxDelay = const Duration(seconds: 5), int maxAttempts = 5}) Future<R>

Typedefs

ObtainToken<T> = Future<T> Function(Client client, String uri)
RefreshToken<T> = Future<T> Function(T? token, String? uri, Client client)
ShouldRefresh<T> = bool Function(GrpcError? error, T? token)
Signature for shouldRefresh on Fresh.
TokenHeaderBuilder<T> = Map<String, String> Function(T token)
Function responsible for building the token header(s) give a token.

Exceptions / Errors

RevokeTokenException
An Exception that should be thrown when overriding refreshToken if the refresh fails and should result in a force-logout.