async-refresh-tokens-0.2.0.0: Package implementing core logic for refreshing of expiring access tokens

Copyright(c) Moritz Schulte 2017
LicenseBSD3
Maintainermtesseract@silverratio.net
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Control.Concurrent.Async.Refresh.Tokens

Description

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.

Synopsis

Documentation

class IsToken t where Source #

Type class for tokens.

Minimal complete definition

tokenScopes

Methods

tokenScopes :: proxy t -> [Text] Source #

Desired scopes for this configuration.

tokenName :: proxy t -> Text Source #

Human readable name for this token, including default implementation.

newtype Token t Source #

Type containing a token. t is a phantom type, which can be used for making different tokens distinguishable at the type level.

Constructors

Token 

Fields

Instances

Eq (Token k t) Source # 

Methods

(==) :: Token k t -> Token k t -> Bool #

(/=) :: Token k t -> Token k t -> Bool #

Show (Token k t) Source # 

Methods

showsPrec :: Int -> Token k t -> ShowS #

show :: Token k t -> String #

showList :: [Token k t] -> ShowS #

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.

Constructors

IsToken t => RequestToken 

Fields

data RefreshResult a :: * -> * #

Data type returned by async refresh actions.

Constructors

RefreshResult 

Fields

Instances

type TokenStore t = TVar (Either SomeException (Token t)) Source #

Type synonym representing a token store, which is an Either wrapped in a TVar.

data TokenConf m Source #

Type representing a configuration for this package.

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) => proxy 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.