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

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] [Publish]

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]


Versions 0.1.0,,,,,
Change log None available
Dependencies async-refresh (>=, base (>=4.7 && <5), bytestring, formatting, lifted-async, microlens (>=0.4), microlens-th (>=0.4), monad-control, monad-logger, safe-exceptions, stm, text [details]
License BSD-3-Clause
Copyright (c) 2017 Moritz Schulte
Author Moritz Schulte
Category Control
Home page
Source repo head: git clone
Uploaded by mtesseract at 2017-07-04T09:44:11Z



Maintainer's Corner

For package maintainers and hackage trustees

Readme for async-refresh-tokens-

[back to package description]

async-refresh-tokens Hackage version Stackage version Build Status


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



{-# LANGUAGE OverloadedStrings   #-}

data TokenFoo

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

createTokenStoreFoo :: LoggingT IO (TokenStore TokenFoo)
createTokenStoreFoo = 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