-- 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 2.3.0
-- | 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 -> Text -> URIRef Absolute -> URIRef Absolute -> URIRef Absolute -> OAuth2
[oauth2ClientId] :: OAuth2 -> Text
[oauth2ClientSecret] :: OAuth2 -> Text
[oauth2AuthorizeEndpoint] :: OAuth2 -> URIRef Absolute
[oauth2TokenEndpoint] :: OAuth2 -> URIRef Absolute
[oauth2RedirectUri] :: OAuth2 -> URIRef Absolute
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
data APIAuthenticationMethod
-- | Provides in Authorization header
AuthInRequestHeader :: APIAuthenticationMethod
-- | Provides in request body
AuthInRequestBody :: APIAuthenticationMethod
-- | Provides in request query parameter
AuthInRequestQuery :: APIAuthenticationMethod
data ClientAuthenticationMethod
ClientSecretBasic :: ClientAuthenticationMethod
ClientSecretPost :: ClientAuthenticationMethod
-- | type synonym of post body content
type PostBody = [(ByteString, ByteString)]
type QueryParams = [(ByteString, ByteString)]
defaultRequestHeaders :: [(HeaderName, 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.Classes.Eq Network.OAuth.OAuth2.Internal.OAuth2
instance GHC.Show.Show Network.OAuth.OAuth2.Internal.OAuth2
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 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.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.ExchangeToken
instance Data.Aeson.Types.FromJSON.FromJSON Network.OAuth.OAuth2.Internal.ExchangeToken
instance GHC.Show.Show Network.OAuth.OAuth2.Internal.ExchangeToken
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 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.Classes.Ord Network.OAuth.OAuth2.Internal.APIAuthenticationMethod
instance GHC.Classes.Eq Network.OAuth.OAuth2.Internal.APIAuthenticationMethod
instance GHC.Classes.Ord Network.OAuth.OAuth2.Internal.ClientAuthenticationMethod
instance GHC.Classes.Eq Network.OAuth.OAuth2.Internal.ClientAuthenticationMethod
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
instance Data.Default.Class.Default Network.OAuth.OAuth2.Internal.OAuth2
-- | A simple http client to request OAuth2 tokens and several utils.
module Network.OAuth.OAuth2.HttpClient
-- | Conduct an authorized GET request and return response as JSON. Inject
-- Access Token to Authorization Header.
-- | Deprecated: use authGetJSONInternal
authGetJSON :: FromJSON b => Manager -> AccessToken -> URI -> ExceptT ByteString IO b
-- | Conduct an authorized GET request. Inject Access Token to
-- Authorization Header.
authGetBS :: Manager -> AccessToken -> URI -> ExceptT ByteString IO ByteString
-- | Same to authGetBS but set access token to query parameter
-- rather than header
-- | Deprecated: use authGetBSInternal
authGetBS2 :: Manager -> AccessToken -> URI -> ExceptT ByteString IO ByteString
-- | Conduct an authorized GET request and return response as JSON. Allow
-- to specify how to append AccessToken.
authGetJSONInternal :: FromJSON b => Set APIAuthenticationMethod -> Manager -> AccessToken -> URI -> ExceptT ByteString IO b
-- | Conduct an authorized GET request and return response as ByteString.
-- Allow to specify how to append AccessToken.
authGetBSInternal :: Set APIAuthenticationMethod -> Manager -> AccessToken -> URI -> ExceptT ByteString IO ByteString
-- | Conduct POST request and return response as JSON. Inject Access Token
-- to Authorization Header.
-- | Deprecated: use authPostJSONInternal
authPostJSON :: FromJSON b => Manager -> AccessToken -> URI -> PostBody -> ExceptT ByteString IO b
-- | Conduct POST request. Inject Access Token to http header
-- (Authorization)
authPostBS :: Manager -> AccessToken -> URI -> PostBody -> ExceptT ByteString IO ByteString
-- | Conduct POST request. Inject Access Token to both http header
-- (Authorization) and request body.
-- | Deprecated: use authPostBSInternal
authPostBS1 :: Manager -> AccessToken -> URI -> PostBody -> ExceptT ByteString IO ByteString
-- | Conduct POST request with access token only in the request body but
-- header.
-- | Deprecated: use authPostBSInternal
authPostBS2 :: Manager -> AccessToken -> URI -> PostBody -> ExceptT ByteString IO ByteString
-- | Conduct POST request with access token only in the header and not in
-- body
-- | Deprecated: use authPostBSInternal
authPostBS3 :: Manager -> AccessToken -> URI -> PostBody -> ExceptT ByteString IO ByteString
-- | Conduct POST request and return response as JSON. Allow to specify how
-- to append AccessToken.
authPostJSONInternal :: FromJSON a => Set APIAuthenticationMethod -> Manager -> AccessToken -> URI -> PostBody -> ExceptT ByteString IO a
-- | Conduct POST request and return response as ByteString. Allow to
-- specify how to append AccessToken.
authPostBSInternal :: Set APIAuthenticationMethod -> Manager -> AccessToken -> URI -> PostBody -> ExceptT ByteString IO ByteString
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
-- | Prepare the authorization URL. Redirect to this URL asking for user
-- interactive authentication.
authorizationUrl :: OAuth2 -> URI
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
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
-- | Prepare the URL and the request body query for fetching an access
-- token.
accessTokenUrl :: OAuth2 -> ExchangeToken -> (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)
clientSecretPost :: OAuth2 -> PostBody
-- | 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 -> ExceptT (OAuth2Error Errors) IO OAuth2Token
-- | Deprecated: renamed to fetchAccessTokenInternal
fetchAccessToken2 :: Manager -> OAuth2 -> ExchangeToken -> ExceptT (OAuth2Error Errors) IO OAuth2Token
fetchAccessTokenInternal :: ClientAuthenticationMethod -> Manager -> OAuth2 -> ExchangeToken -> ExceptT (OAuth2Error Errors) IO 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 -> ExceptT (OAuth2Error Errors) IO OAuth2Token
-- | Deprecated: renamed to fetchAccessTokenInternal
refreshAccessToken2 :: Manager -> OAuth2 -> RefreshToken -> ExceptT (OAuth2Error Errors) IO OAuth2Token
refreshAccessTokenInternal :: ClientAuthenticationMethod -> Manager -> OAuth2 -> RefreshToken -> ExceptT (OAuth2Error Errors) IO OAuth2Token
-- | Conduct post request and return response as JSON.
doJSONPostRequest :: (FromJSON err, FromJSON a) => Manager -> OAuth2 -> URI -> PostBody -> ExceptT (OAuth2Error err) IO a
-- | Conduct post request.
doSimplePostRequest :: FromJSON err => Manager -> OAuth2 -> URI -> PostBody -> ExceptT (OAuth2Error err) IO ByteString
-- | Parses a Response to to OAuth2Result
handleOAuth2TokenResponse :: FromJSON err => Response ByteString -> Either (OAuth2Error err) ByteString
-- | Try parseResponseJSON, if failed then parses the
-- OAuth2Result BSL.ByteString that contains not JSON but a
-- Query String.
parseResponseFlexible :: (FromJSON err, FromJSON a) => ByteString -> Either (OAuth2Error err) a
-- | Parses a OAuth2Result BSL.ByteString that contains not JSON
-- but a Query String
parseResponseString :: (FromJSON err, FromJSON a) => ByteString -> Either (OAuth2Error err) a
-- | Set several header values: + userAgennt : hoauth2 + accept :
-- `application/json`
addDefaultRequestHeaders :: Request -> Request
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 lightweight oauth2 haskell binding.
module Network.OAuth.OAuth2
-- | 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)
-- | Using a Refresh Token. Obtain a new access token by sending a refresh
-- token to the Authorization server.
refreshAccessTokenUrl :: OAuth2 -> RefreshToken -> (URI, PostBody)
clientSecretPost :: OAuth2 -> PostBody
-- | 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 -> ExceptT (OAuth2Error Errors) IO OAuth2Token
-- | Deprecated: renamed to fetchAccessTokenInternal
fetchAccessToken2 :: Manager -> OAuth2 -> ExchangeToken -> ExceptT (OAuth2Error Errors) IO OAuth2Token
fetchAccessTokenInternal :: ClientAuthenticationMethod -> Manager -> OAuth2 -> ExchangeToken -> ExceptT (OAuth2Error Errors) IO 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 -> ExceptT (OAuth2Error Errors) IO OAuth2Token
-- | Deprecated: renamed to fetchAccessTokenInternal
refreshAccessToken2 :: Manager -> OAuth2 -> RefreshToken -> ExceptT (OAuth2Error Errors) IO OAuth2Token
refreshAccessTokenInternal :: ClientAuthenticationMethod -> Manager -> OAuth2 -> RefreshToken -> ExceptT (OAuth2Error Errors) IO OAuth2Token
-- | Conduct post request and return response as JSON.
doJSONPostRequest :: (FromJSON err, FromJSON a) => Manager -> OAuth2 -> URI -> PostBody -> ExceptT (OAuth2Error err) IO a
-- | Conduct post request.
doSimplePostRequest :: FromJSON err => Manager -> OAuth2 -> URI -> PostBody -> ExceptT (OAuth2Error err) IO ByteString
-- | Parses a Response to to OAuth2Result
handleOAuth2TokenResponse :: FromJSON err => Response ByteString -> Either (OAuth2Error err) ByteString
-- | Try parseResponseJSON, if failed then parses the
-- OAuth2Result BSL.ByteString that contains not JSON but a
-- Query String.
parseResponseFlexible :: (FromJSON err, FromJSON a) => ByteString -> Either (OAuth2Error err) a
-- | Parses a OAuth2Result BSL.ByteString that contains not JSON
-- but a Query String
parseResponseString :: (FromJSON err, FromJSON a) => ByteString -> Either (OAuth2Error err) a
-- | Set several header values: + userAgennt : hoauth2 + accept :
-- `application/json`
addDefaultRequestHeaders :: Request -> Request