-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | hoauth2 -- -- Haskell OAuth2 authentication. -- -- Tested following services -- -- @package hoauth2 @version 0.2.3 -- | A simple OAuth2 Haskell binding. (This is supposed to be independent -- with http client.) module Network.OAuth2.OAuth2 -- | Query Parameter Representation -- -- TODO: 1. add a base endpoint URI. 2. May to be State Transform data OAuth2 OAuth2 :: ByteString -> ByteString -> ByteString -> ByteString -> Maybe ByteString -> Maybe ByteString -> OAuth2 oauthClientId :: OAuth2 -> ByteString oauthClientSecret :: OAuth2 -> ByteString oauthOAuthorizeEndpoint :: OAuth2 -> ByteString oauthAccessTokenEndpoint :: OAuth2 -> ByteString oauthCallback :: OAuth2 -> Maybe ByteString oauthAccessToken :: OAuth2 -> Maybe ByteString -- | Simple Exception representation. data OAuthException OAuthException :: String -> OAuthException -- | The gained Access Token. Use Data.Aeson.decode to decode -- string to AccessToken. The refresheToken is special -- at some case, e.g. -- https:developers.google.comaccountsdocs/OAuth2 data AccessToken AccessToken :: ByteString -> Maybe ByteString -> AccessToken accessToken :: AccessToken -> ByteString refreshToken :: AccessToken -> Maybe ByteString -- | type synonym of query parameters type QueryParams = [(ByteString, ByteString)] -- | type synonym of post body content type PostBody = [(ByteString, ByteString)] -- | type synonym of a URI type URI = ByteString -- | Append query parameters appendQueryParam :: URI -> QueryParams -> URI -- | lift value in the Maybe and abonda Nothing transform' :: [(a, Maybe b)] -> [(a, b)] -- | Prepare the authorization URL. Redirect to this URL asking for user -- interactive authentication. authorizationUrl :: OAuth2 -> URI -- | Prepare URL and the request body query for fetching access token. accessTokenUrl :: OAuth2 -> ByteString -> (URI, PostBody) accessTokenUrl' :: OAuth2 -> ByteString -> Maybe ByteString -> (URI, PostBody) -- | Using a Refresh Token. obtain a new access token by sending a refresh -- token to the Authorization server. refreshAccessTokenUrl :: OAuth2 -> ByteString -> (URI, PostBody) -- | For GET method API. appendAccessToken :: URI -> OAuth2 -> URI -- | Create QueryParams with given access token value. accessTokenToParam :: ByteString -> QueryParams instance Typeable OAuthException instance Show OAuth2 instance Eq OAuth2 instance Show OAuthException instance Eq OAuthException instance Show AccessToken instance FromJSON AccessToken instance Exception OAuthException -- | A simple http client for request OAuth2 tokens and several utils. module Network.OAuth2.HTTP.HttpClient -- | Request (POST method) access token URL in order to get -- AccessToken. -- -- FIXME: what if requestAccessToken' return error? requestAccessToken :: OAuth2 -> ByteString -> IO (Maybe AccessToken) -- | Request the Refresh Token. refreshAccessToken :: OAuth2 -> ByteString -> IO (Maybe AccessToken) -- | Conduct post request in IO monad. postRequest :: (URI, PostBody) -> IO ByteString -- | Conduct GET request with given URL. doSimpleGetRequest :: MonadIO m => String -> m (Response ByteString) -- | Conduct GET request with given URL by append extra parameters -- provided. doGetRequest :: MonadIO m => String -> [(ByteString, ByteString)] -> m (Response ByteString) -- | Conduct POST request with given URL with post body data. doPostRequst :: MonadIO m => String -> [(ByteString, ByteString)] -> m (Response ByteString)