-- 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.2.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 -> Text -> URIRef Absolute -> URIRef Absolute -> Maybe (URIRef Absolute) -> OAuth2
[oauth2ClientId] :: OAuth2 -> Text
[oauth2ClientSecret] :: OAuth2 -> Text
[oauth2AuthorizeEndpoint] :: OAuth2 -> URIRef Absolute
[oauth2TokenEndpoint] :: OAuth2 -> URIRef Absolute
[oauth2RedirectUri] :: OAuth2 -> Maybe (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
-- | 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.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 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.Hashable.Class.Hashable Network.OAuth.OAuth2.Internal.OAuth2
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 -> ExceptT (OAuth2Error Errors) IO OAuth2Token
-- | Please read the docs of fetchAccessToken.
fetchAccessToken2 :: 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
-- | Please read the docs of refreshAccessToken.
refreshAccessToken2 :: Manager -> OAuth2 -> RefreshToken -> ExceptT (OAuth2Error Errors) IO OAuth2Token
-- | Conduct post request.
doSimplePostRequest :: FromJSON err => Manager -> OAuth2 -> URI -> PostBody -> ExceptT (OAuth2Error err) IO ByteString
-- | Conduct an authorized GET request and return response as JSON. Inject
-- Access Token to Authorization Header.
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
authGetBS2 :: Manager -> AccessToken -> URI -> ExceptT ByteString IO ByteString
-- | Conduct POST request and return response as JSON. Inject Access Token
-- to Authorization Header and request body.
authPostJSON :: FromJSON b => Manager -> AccessToken -> URI -> PostBody -> ExceptT ByteString IO b
-- | Conduct POST request. Inject Access Token to http header
-- (Authorization) and request body.
authPostBS :: Manager -> AccessToken -> URI -> PostBody -> ExceptT ByteString IO ByteString
-- | Conduct POST request with access token only in the request body but
-- header.
authPostBS2 :: Manager -> AccessToken -> URI -> PostBody -> ExceptT ByteString IO ByteString
-- | Conduct POST request with access token only in the header and not in
-- body
authPostBS3 :: Manager -> AccessToken -> URI -> ExceptT ByteString IO ByteString
-- | Send an HTTP request including the Authorization header with the
-- specified access token.
authRequest :: Request -> (Request -> Request) -> Manager -> ExceptT ByteString IO ByteString
-- | A lightweight oauth2 haskell binding.
module Network.OAuth.OAuth2