Copyright | (c) Moritz Schulte 2017 |
---|---|
License | BSD3 |
Maintainer | mtesseract@silverratio.net |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
The async-refresh-tokens package is built on top of the async-refresh package and provides the core logic for renewal of expiring access tokens according to user-provided actions.
- class IsToken t where
- newtype Token t = Token {}
- data TokenRefresher
- tokenRefresherAsync :: TokenRefresher -> Async ()
- data RequestToken m = IsToken t => RequestToken {
- requestTokenStore :: TokenStore t
- requestTokenAction :: m (RefreshResult (Token t))
- data RefreshResult a :: * -> * = RefreshResult {
- refreshResult :: a
- refreshExpiry :: Maybe Int
- type TokenStore t = TVar (Either SomeException (Token t))
- data TokenConf m
- newTokenRefresher :: forall m. (MonadIO m, MonadBaseControl IO m, MonadMask m, MonadLogger m, Forall (Pure m)) => TokenConf m -> m TokenRefresher
- newEmptyTokenStore :: (MonadIO m, IsToken t) => m (TVar (Either SomeException (Token t)))
- defaultTokenConf :: TokenConf m
- tokenConfSetFactor :: Double -> TokenConf m -> TokenConf m
- tokenConfAddRequest :: RequestToken m -> TokenConf m -> TokenConf m
Documentation
Type containing a token. t
is a phantom type, which can be used
for making different tokens distinguishable at the type level.
data TokenRefresher Source #
Type representing a running token refresher.
tokenRefresherAsync :: TokenRefresher -> Async () Source #
Extract the Async
handle from the provided TokenRefresher
.
data RequestToken m Source #
Type wrapping a token request using existential quantification.
IsToken t => RequestToken | |
|
data RefreshResult a :: * -> * #
Data type returned by async refresh actions.
RefreshResult | |
|
Show a => Show (RefreshResult a) | |
type TokenStore t = TVar (Either SomeException (Token t)) Source #
newTokenRefresher :: forall m. (MonadIO m, MonadBaseControl IO m, MonadMask m, MonadLogger m, Forall (Pure m)) => TokenConf m -> m TokenRefresher Source #
Start a new token refresher for the provided configuration.
Returns a TokenRefresher
handle representing the running token
refresher.
newEmptyTokenStore :: (MonadIO m, IsToken t) => m (TVar (Either SomeException (Token t))) Source #
Create a new empty token store for the provided token type.
defaultTokenConf :: TokenConf m Source #
Produce default token configuration.
tokenConfSetFactor :: Double -> TokenConf m -> TokenConf m Source #
Set the token refreshing factor, which is the factor in the
closed interval [0, 1] by which an "expires_in" duration is to be
scaled. See defaultRefreshTimeFactor
.
tokenConfAddRequest :: RequestToken m -> TokenConf m -> TokenConf m Source #
Add a token request to the given token configuration.