Copyright | (C) Richard Cook 2018 |
---|---|
License | MIT |
Maintainer | rcook@rcook.org |
Stability | stable |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
This package provides basic support of OAuth2 authentication for Req.
- newtype AccessToken = AccessToken Text
- data AccessTokenRequest = AccessTokenRequest AuthCode
- data AccessTokenResponse = AccessTokenResponse TokenPair
- data App = App {}
- newtype ClientId = ClientId Text
- data ClientPair = ClientPair ClientId ClientSecret
- newtype ClientSecret = ClientSecret Text
- type OAuth2 = StateT TokenPair IO
- type PromptForCallbackUri = URI -> IO URI
- newtype RefreshToken = RefreshToken Text
- data TokenPair = TokenPair AccessToken RefreshToken
- type UpdateTokenPair = TokenPair -> IO ()
- evalOAuth2 :: TokenPair -> OAuth2 a -> IO a
- fetchAccessToken :: App -> AccessTokenRequest -> IO (Either String AccessTokenResponse)
- getAuthCode :: App -> ClientId -> PromptForCallbackUri -> IO AuthCode
- oAuth2Get :: (Value -> Parser a) -> Url Https -> App -> OAuth2 a
- runOAuth2 :: TokenPair -> OAuth2 a -> IO (a, TokenPair)
Documentation
A web API application
data ClientPair Source #
OAuth2 client ID/client secret pair
newtype ClientSecret Source #
OAuth2 client secret
OAuth2 access/refresh token pair
type UpdateTokenPair = TokenPair -> IO () Source #
Action invoked in response to update to access/refresh token pair
fetchAccessToken :: App -> AccessTokenRequest -> IO (Either String AccessTokenResponse) Source #
Gets OAuth2 access token
Implements standard OAuth2 access token workflow for web server apps as described here.
We don't pass client_secret
because that would be silly. We also don't bother
with redirect_uri
since this do not seem to be required.
getAuthCode :: App -> ClientId -> PromptForCallbackUri -> IO AuthCode Source #
Gets OAuth2 authorization code
Implements standard OAuth2 authorization workflow for web server apps as described here.
We don't bother with redirect_uri
or state
since they do not seem
to be required.