async-refresh-tokens-0.4.0.0: Package implementing core logic for refreshing of expiring access tokens
Copyright(c) Moritz Clasmeier 2017-2018
LicenseBSD3
Maintainer[email protected]
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 :: k) 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 :: k) 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

Instances details
Show (Token t) Source # 
Instance details

Defined in Control.Concurrent.Async.Refresh.Tokens.Types

Methods

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

show :: Token t -> String #

showList :: [Token t] -> ShowS #

Eq (Token t) Source # 
Instance details

Defined in Control.Concurrent.Async.Refresh.Tokens.Types

Methods

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

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

data TokenRefresher Source #

Type representing a running token refresher.

tokenRefresherAsync :: TokenRefresher -> Async () Source #

Extract the Async handle from the provided TokenRefresher.

data RequestToken (m :: Type -> Type) 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

Instances details
Show a => Show (RefreshResult a) 
Instance details

Defined in Control.Concurrent.Async.Refresh.Types

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

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

data TokenConf (m :: Type -> Type) Source #

Type representing a configuration for this package.

newTokenRefresher :: (MonadUnliftIO m, MonadMask m, MonadLogger 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 :: forall {k} m (t :: k). (MonadIO m, IsToken t) => m (TVar (Either SomeException (Token t))) Source #

Create a new empty token store for the provided token type.

defaultTokenConf :: forall (m :: Type -> Type). TokenConf m Source #

Produce default token configuration.

tokenConfSetFactor :: forall (m :: Type -> Type). 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 :: forall (m :: Type -> Type). RequestToken m -> TokenConf m -> TokenConf m Source #

Add a token request to the given token configuration.