-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | hoauth2 -- -- Haskell OAuth2 authentication. -- -- Tested following services -- -- @package hoauth2 @version 0.3.0 -- | A simple OAuth2 Haskell binding. (This is supposed to be independent -- with http client.) module Network.OAuth.OAuth2 -- | Query Parameter Representation 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 -- | TODO: why not Maybe AccessToken??? 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 -- | Access Code that is required for fetching Access Token type AccessCode = ByteString -- | 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 -> AccessCode -> (URI, PostBody) accessTokenUrl' :: OAuth2 -> AccessCode -> 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) -- | Append query parameters with ? appendQueryParam :: URI -> QueryParams -> URI -- | Append query parameters with &. appendQueryParam' :: URI -> QueryParams -> URI -- | For GET method API. appendAccessToken :: URI -> OAuth2 -> URI -- | Create QueryParams with given access token value. accessTokenToParam :: ByteString -> QueryParams -- | lift value in the Maybe and abonda Nothing transform' :: [(a, Maybe b)] -> [(a, b)] 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.OAuth.OAuth2.HttpClient -- | Request (via POST method) Access Token. -- -- 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. doSimplePostRequest :: (URI, PostBody) -> IO ByteString -- | Conduct post request and return response as JSON. doJSONPostRequest :: FromJSON a => (URI, PostBody) -> IO (Maybe a) -- | Conduct GET request. doSimpleGetRequest :: URI -> IO ByteString -- | Conduct GET request and return response as JSON. doJSONGetRequest :: FromJSON a => URI -> IO (Maybe a) -- | Conduct GET request with given URL by append extra parameters -- provided. doGetRequest :: String -> [(ByteString, ByteString)] -> IO (Response ByteString) -- | TODO: can not be `Request m -> Request m`, why?? doGetRequestWithReq :: String -> [(ByteString, ByteString)] -> (Request (ResourceT IO) -> Request (ResourceT IO)) -> IO (Response ByteString) -- | Conduct POST request with given URL with post body data. doPostRequst :: String -> [(ByteString, ByteString)] -> IO (Response ByteString) doPostRequstWithReq :: String -> [(ByteString, ByteString)] -> (Request (ResourceT IO) -> Request (ResourceT IO)) -> IO (Response ByteString) handleResponse :: Response ByteString -> IO ByteString updateRequestHeaders :: Request m -> Request m bsToS :: ByteString -> String