The async-refresh-tokens package

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.

[maintain]

This package can be used for renewal of expiring access tokens according to user-provided actions. Tokens will be stored in a transactional variable (TVar).


[Skip to ReadMe]

Properties

Versions0.0.3, 0.1.0, 0.2.0.0, 0.3.0.0, 0.3.0.1
Change logNone available
Dependenciesasync-refresh, base (>=4.7 && <5), bytestring, formatting, lens, lifted-async, monad-control, monad-logger, safe-exceptions, stm, text [details]
LicenseBSD3
Copyright(c) 2017 Moritz Schulte
AuthorMoritz Schulte
Maintainermtesseract@silverratio.net
CategoryControl
Home pagehttps://github.com/mtesseract/async-refresh-tokens#readme
Source repositoryhead: git clone https://github.com/mtesseract/async-refresh-tokens
UploadedTue Apr 11 14:08:58 UTC 2017 by mtesseract

Modules

Downloads

Maintainers' corner

For package maintainers and hackage trustees


Readme for async-refresh-tokens-0.0.3

[back to package description]

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

Example

{-# LANGUAGE DataKinds           #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE PolyKinds           #-}

data MyAppTokens = TokenFoo | TokenBar

instance IsToken 'TokenFoo where
  tokenScopes _ = ["foo.read", "foo.write"]

createTokenStoreFoo :: IO (TokenStore 'TokenFoo)
createTokenStoreFoo = runStderrLoggingT $ do
  tokenFoo <- newEmptyTokenStore (Proxy :: Proxy 'TokenFoo)
  let conf = defaultTokenConf
             & tokenConfAddRequest (RequestToken tokenFoo actionFoo)
  _ <- newTokenRefresher conf
  return tokenFoo

  where actionFoo :: (MonadIO m, IsToken t) => m (RefreshResult (Token t))
        actionFoo =
          return $ RefreshResult (Token "secret-foo-token") Nothing