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 for OAuth2 authentication for Req.
Synopsis
- 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)
- fetchRefreshToken :: App -> RefreshTokenRequest -> IO (Either String RefreshTokenResponse)
- getAuthCode :: App -> ClientId -> PromptForCallbackUri -> IO AuthCode
- oAuth2Get :: (Value -> Parser a) -> Url 'Https -> App -> OAuth2 a
- runOAuth2 :: TokenPair -> OAuth2 a -> IO (a, TokenPair)
Documentation
newtype AccessToken Source #
OAuth2 access token
Instances
Show AccessToken Source # | |
Defined in Network.HTTP.Req.OAuth2.Internal.Types showsPrec :: Int -> AccessToken -> ShowS # show :: AccessToken -> String # showList :: [AccessToken] -> ShowS # |
A web API application
data ClientPair Source #
OAuth2 client ID/client secret pair
Instances
Eq ClientPair Source # | |
Defined in Network.HTTP.Req.OAuth2.Internal.Types (==) :: ClientPair -> ClientPair -> Bool # (/=) :: ClientPair -> ClientPair -> Bool # | |
Show ClientPair Source # | |
Defined in Network.HTTP.Req.OAuth2.Internal.Types showsPrec :: Int -> ClientPair -> ShowS # show :: ClientPair -> String # showList :: [ClientPair] -> ShowS # |
newtype ClientSecret Source #
OAuth2 client secret
Instances
Eq ClientSecret Source # | |
Defined in Network.HTTP.Req.OAuth2.Internal.Types (==) :: ClientSecret -> ClientSecret -> Bool # (/=) :: ClientSecret -> ClientSecret -> Bool # | |
Show ClientSecret Source # | |
Defined in Network.HTTP.Req.OAuth2.Internal.Types showsPrec :: Int -> ClientSecret -> ShowS # show :: ClientSecret -> String # showList :: [ClientSecret] -> ShowS # |
newtype RefreshToken Source #
OAuth2 refresh token
Instances
Show RefreshToken Source # | |
Defined in Network.HTTP.Req.OAuth2.Internal.Types showsPrec :: Int -> RefreshToken -> ShowS # show :: RefreshToken -> String # showList :: [RefreshToken] -> ShowS # |
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.