This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

Maintainers' corner

Readme for async-refresh-tokens-0.2.0.1

async-refresh-tokens

About

This is Haskell library built on top of the async-refresh package
implementing the logic for refreshing of expiring access tokens.

Usage

Create new token types.

Make the tokens be instances of the IsToken type classes by
defining the tokenScopes method and (optionally) tokenName (a
human readable label for this token).

Use newEmptyTokenStore to create a new token stores (token stores
are basically TVars containing the tokens wrapped in Either
SomeException).

Create a new configuration by adjusting defaultTokenConf using the
functions tokenConfAddRequest and tokenConfSetFactor. The
function tokenConfAddRequest expects values of type RequestToken
— these values encapsulate the token stores together with a
token-refreshing action.

Use newTokenRefresher to initiate token refreshing for each
registered token refreshing request.

To use the current token, extract it from the TVar using
readTVar (and pattern matching on Right).