-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Haskell OAuth2 authentication client
--
-- Haskell OAuth2 authentication client. Tested with the following
-- services:
--
--
@package hoauth2
@version 1.16.0
module Network.OAuth.OAuth2.AuthorizationRequest
-- | Authorization Code Grant Error Responses
-- https://tools.ietf.org/html/rfc6749#section-4.1.2.1 Implicit
-- Grant Error Responses
-- https://tools.ietf.org/html/rfc6749#section-4.2.2.1
data Errors
InvalidRequest :: Errors
UnauthorizedClient :: Errors
AccessDenied :: Errors
UnsupportedResponseType :: Errors
InvalidScope :: Errors
ServerError :: Errors
TemporarilyUnavailable :: Errors
instance GHC.Generics.Generic Network.OAuth.OAuth2.AuthorizationRequest.Errors
instance GHC.Classes.Eq Network.OAuth.OAuth2.AuthorizationRequest.Errors
instance GHC.Show.Show Network.OAuth.OAuth2.AuthorizationRequest.Errors
instance Data.Aeson.Types.FromJSON.FromJSON Network.OAuth.OAuth2.AuthorizationRequest.Errors
instance Data.Aeson.Types.ToJSON.ToJSON Network.OAuth.OAuth2.AuthorizationRequest.Errors
-- | A simple OAuth2 Haskell binding. (This is supposed to be independent
-- of the http client used.)
module Network.OAuth.OAuth2.Internal
-- | Query Parameter Representation
data OAuth2
OAuth2 :: Text -> Maybe Text -> URI -> URI -> Maybe URI -> OAuth2
[oauthClientId] :: OAuth2 -> Text
[oauthClientSecret] :: OAuth2 -> Maybe Text
[oauthOAuthorizeEndpoint] :: OAuth2 -> URI
[oauthAccessTokenEndpoint] :: OAuth2 -> URI
[oauthCallback] :: OAuth2 -> Maybe URI
newtype AccessToken
AccessToken :: Text -> AccessToken
[atoken] :: AccessToken -> Text
newtype RefreshToken
RefreshToken :: Text -> RefreshToken
[rtoken] :: RefreshToken -> Text
newtype IdToken
IdToken :: Text -> IdToken
[idtoken] :: IdToken -> Text
newtype ExchangeToken
ExchangeToken :: Text -> ExchangeToken
[extoken] :: ExchangeToken -> Text
-- | The gained Access Token. Use Data.Aeson.decode to decode
-- string to AccessToken. The refreshToken is special
-- in some cases, e.g.
-- https://developers.google.com/accounts/docs/OAuth2
data OAuth2Token
OAuth2Token :: AccessToken -> Maybe RefreshToken -> Maybe Int -> Maybe Text -> Maybe IdToken -> OAuth2Token
[accessToken] :: OAuth2Token -> AccessToken
[refreshToken] :: OAuth2Token -> Maybe RefreshToken
[expiresIn] :: OAuth2Token -> Maybe Int
[tokenType] :: OAuth2Token -> Maybe Text
[idToken] :: OAuth2Token -> Maybe IdToken
parseIntFlexible :: Value -> Parser Int
data OAuth2Error a
OAuth2Error :: Either Text a -> Maybe Text -> Maybe (URIRef Absolute) -> OAuth2Error a
[error] :: OAuth2Error a -> Either Text a
[errorDescription] :: OAuth2Error a -> Maybe Text
[errorUri] :: OAuth2Error a -> Maybe (URIRef Absolute)
parseOAuth2Error :: FromJSON err => ByteString -> OAuth2Error err
mkDecodeOAuth2Error :: ByteString -> String -> OAuth2Error err
-- | Is either Left containing an error or Right containg a
-- result
type OAuth2Result err a = Either (OAuth2Error err) a
-- | type synonym of post body content
type PostBody = [(ByteString, ByteString)]
type QueryParams = [(ByteString, ByteString)]
-- | Prepare the authorization URL. Redirect to this URL asking for user
-- interactive authentication.
authorizationUrl :: OAuth2 -> URI
-- | Prepare the URL and the request body query for fetching an access
-- token.
accessTokenUrl :: OAuth2 -> ExchangeToken -> (URI, PostBody)
-- | Prepare the URL and the request body query for fetching an access
-- token, with optional grant type.
accessTokenUrl' :: OAuth2 -> ExchangeToken -> Maybe Text -> (URI, PostBody)
-- | Using a Refresh Token. Obtain a new access token by sending a refresh
-- token to the Authorization server.
refreshAccessTokenUrl :: OAuth2 -> RefreshToken -> (URI, PostBody)
-- | For GET method API.
appendAccessToken :: URIRef a -> AccessToken -> URIRef a
-- | Create QueryParams with given access token value.
accessTokenToParam :: AccessToken -> [(ByteString, ByteString)]
appendQueryParams :: [(ByteString, ByteString)] -> URIRef a -> URIRef a
uriToRequest :: MonadThrow m => URI -> m Request
requestToUri :: Request -> URI
hostLens :: Lens' Request ByteString
portLens :: Lens' Request Int
instance GHC.Generics.Generic (Network.OAuth.OAuth2.Internal.OAuth2Error a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Network.OAuth.OAuth2.Internal.OAuth2Error a)
instance GHC.Show.Show a => GHC.Show.Show (Network.OAuth.OAuth2.Internal.OAuth2Error a)
instance GHC.Generics.Generic Network.OAuth.OAuth2.Internal.OAuth2Token
instance GHC.Show.Show Network.OAuth.OAuth2.Internal.OAuth2Token
instance GHC.Classes.Eq Network.OAuth.OAuth2.Internal.OAuth2Token
instance Data.Aeson.Types.ToJSON.ToJSON Network.OAuth.OAuth2.Internal.ExchangeToken
instance Data.Aeson.Types.FromJSON.FromJSON Network.OAuth.OAuth2.Internal.ExchangeToken
instance GHC.Show.Show Network.OAuth.OAuth2.Internal.ExchangeToken
instance Data.Aeson.Types.ToJSON.ToJSON Network.OAuth.OAuth2.Internal.IdToken
instance Data.Aeson.Types.FromJSON.FromJSON Network.OAuth.OAuth2.Internal.IdToken
instance GHC.Show.Show Network.OAuth.OAuth2.Internal.IdToken
instance GHC.Classes.Eq Network.OAuth.OAuth2.Internal.IdToken
instance Data.Binary.Class.Binary Network.OAuth.OAuth2.Internal.IdToken
instance Data.Aeson.Types.ToJSON.ToJSON Network.OAuth.OAuth2.Internal.RefreshToken
instance Data.Aeson.Types.FromJSON.FromJSON Network.OAuth.OAuth2.Internal.RefreshToken
instance GHC.Show.Show Network.OAuth.OAuth2.Internal.RefreshToken
instance GHC.Classes.Eq Network.OAuth.OAuth2.Internal.RefreshToken
instance Data.Binary.Class.Binary Network.OAuth.OAuth2.Internal.RefreshToken
instance Data.Aeson.Types.ToJSON.ToJSON Network.OAuth.OAuth2.Internal.AccessToken
instance Data.Aeson.Types.FromJSON.FromJSON Network.OAuth.OAuth2.Internal.AccessToken
instance GHC.Show.Show Network.OAuth.OAuth2.Internal.AccessToken
instance GHC.Classes.Eq Network.OAuth.OAuth2.Internal.AccessToken
instance Data.Binary.Class.Binary Network.OAuth.OAuth2.Internal.AccessToken
instance GHC.Classes.Eq Network.OAuth.OAuth2.Internal.OAuth2
instance GHC.Show.Show Network.OAuth.OAuth2.Internal.OAuth2
instance Data.Aeson.Types.FromJSON.FromJSON err => Data.Aeson.Types.FromJSON.FromJSON (Network.OAuth.OAuth2.Internal.OAuth2Error err)
instance Data.Aeson.Types.ToJSON.ToJSON err => Data.Aeson.Types.ToJSON.ToJSON (Network.OAuth.OAuth2.Internal.OAuth2Error err)
instance Data.Binary.Class.Binary Network.OAuth.OAuth2.Internal.OAuth2Token
instance Data.Aeson.Types.FromJSON.FromJSON Network.OAuth.OAuth2.Internal.OAuth2Token
instance Data.Aeson.Types.ToJSON.ToJSON Network.OAuth.OAuth2.Internal.OAuth2Token
module Network.OAuth.OAuth2.TokenRequest
-- | Token Error Responses
-- https://tools.ietf.org/html/rfc6749#section-5.2
data Errors
InvalidRequest :: Errors
InvalidClient :: Errors
InvalidGrant :: Errors
UnauthorizedClient :: Errors
UnsupportedGrantType :: Errors
InvalidScope :: Errors
instance GHC.Generics.Generic Network.OAuth.OAuth2.TokenRequest.Errors
instance GHC.Classes.Eq Network.OAuth.OAuth2.TokenRequest.Errors
instance GHC.Show.Show Network.OAuth.OAuth2.TokenRequest.Errors
instance Data.Aeson.Types.FromJSON.FromJSON Network.OAuth.OAuth2.TokenRequest.Errors
instance Data.Aeson.Types.ToJSON.ToJSON Network.OAuth.OAuth2.TokenRequest.Errors
-- | A simple http client to request OAuth2 tokens and several utils.
module Network.OAuth.OAuth2.HttpClient
-- | Fetch OAuth2 Token with authenticate in request header.
--
-- OAuth2 spec allows client_id and client_secret to
-- either be sent in the header (as basic authentication) OR as form/url
-- params. The OAuth server can choose to implement only one, or both.
-- Unfortunately, there is no way for the OAuth client (i.e. this
-- library) to know which method to use. Please take a look at the
-- documentation of the service that you are integrating with and either
-- use fetchAccessToken or fetchAccessToken2
fetchAccessToken :: Manager -> OAuth2 -> ExchangeToken -> IO (OAuth2Result Errors OAuth2Token)
-- | Please read the docs of fetchAccessToken.
fetchAccessToken2 :: Manager -> OAuth2 -> ExchangeToken -> IO (OAuth2Result Errors OAuth2Token)
-- | Fetch a new AccessToken with the Refresh Token with authentication in
-- request header. OAuth2 spec allows client_id and
-- client_secret to either be sent in the header (as basic
-- authentication) OR as form/url params. The OAuth server can choose to
-- implement only one, or both. Unfortunately, there is no way for the
-- OAuth client (i.e. this library) to know which method to use. Please
-- take a look at the documentation of the service that you are
-- integrating with and either use refreshAccessToken or
-- refreshAccessToken2
refreshAccessToken :: Manager -> OAuth2 -> RefreshToken -> IO (OAuth2Result Errors OAuth2Token)
-- | Please read the docs of refreshAccessToken.
refreshAccessToken2 :: Manager -> OAuth2 -> RefreshToken -> IO (OAuth2Result Errors OAuth2Token)
-- | Conduct post request.
doSimplePostRequest :: FromJSON err => Manager -> OAuth2 -> URI -> PostBody -> IO (OAuth2Result err ByteString)
-- | Conduct an authorized GET request and return response as JSON.
authGetJSON :: FromJSON b => Manager -> AccessToken -> URI -> IO (Either ByteString b)
-- | Conduct an authorized GET request.
authGetBS :: Manager -> AccessToken -> URI -> IO (Either ByteString ByteString)
-- | same to authGetBS but set access token to query parameter
-- rather than header
authGetBS2 :: Manager -> AccessToken -> URI -> IO (Either ByteString ByteString)
-- | Conduct POST request and return response as JSON.
authPostJSON :: FromJSON b => Manager -> AccessToken -> URI -> PostBody -> IO (Either ByteString b)
-- | Conduct POST request.
authPostBS :: Manager -> AccessToken -> URI -> PostBody -> IO (Either ByteString ByteString)
-- | Conduct POST request with access token in the request body rather
-- header
authPostBS2 :: Manager -> AccessToken -> URI -> PostBody -> IO (Either ByteString ByteString)
-- | Conduct POST request with access token in the header and null in body
authPostBS3 :: Manager -> AccessToken -> URI -> IO (Either ByteString ByteString)
-- | Send an HTTP request including the Authorization header with the
-- specified access token.
authRequest :: Request -> (Request -> Request) -> Manager -> IO (Either ByteString ByteString)
-- | A lightweight oauth2 haskell binding.
module Network.OAuth.OAuth2