Safe Haskell | None |
---|---|
Language | Haskell2010 |
A simple http client to request OAuth2 tokens and several utils.
- fetchAccessToken :: Manager -> OAuth2 -> ByteString -> IO (OAuth2Result AccessToken)
- fetchRefreshToken :: Manager -> OAuth2 -> ByteString -> IO (OAuth2Result AccessToken)
- doJSONPostRequest :: FromJSON a => Manager -> OAuth2 -> URI -> PostBody -> IO (OAuth2Result a)
- doSimplePostRequest :: Manager -> OAuth2 -> URI -> PostBody -> IO (OAuth2Result ByteString)
- authGetJSON :: FromJSON a => Manager -> AccessToken -> URI -> IO (OAuth2Result a)
- authGetBS :: Manager -> AccessToken -> URI -> IO (OAuth2Result ByteString)
- authGetBS' :: Manager -> AccessToken -> URI -> IO (OAuth2Result ByteString)
- authPostJSON :: FromJSON a => Manager -> AccessToken -> URI -> PostBody -> IO (OAuth2Result a)
- authPostBS :: Manager -> AccessToken -> URI -> PostBody -> IO (OAuth2Result ByteString)
- authRequest :: Request -> (Request -> Request) -> Manager -> IO (OAuth2Result ByteString)
- authRequest' :: Request -> (Request -> Request) -> Manager -> IO (Response ByteString)
- handleResponse :: Response ByteString -> OAuth2Result ByteString
- parseResponseJSON :: FromJSON a => OAuth2Result ByteString -> OAuth2Result a
- updateRequestHeaders :: Maybe AccessToken -> Request -> Request
- setMethod :: StdMethod -> Request -> Request
Retrieve access token
:: Manager | HTTP connection manager |
-> OAuth2 | OAuth Data |
-> ByteString | Authentication code gained after authorization |
-> IO (OAuth2Result AccessToken) | Access Token |
Request (via POST method) "Access Token".
:: Manager | HTTP connection manager. |
-> OAuth2 | OAuth context |
-> ByteString | refresh token gained after authorization |
-> IO (OAuth2Result AccessToken) |
Request the "Refresh Token".
:: FromJSON a | |
=> Manager | HTTP connection manager. |
-> OAuth2 | OAuth options |
-> URI | The URL |
-> PostBody | request body |
-> IO (OAuth2Result a) | Response as ByteString |
Conduct post request and return response as JSON.
:: Manager | HTTP connection manager. |
-> OAuth2 | OAuth options |
-> URI | URL |
-> PostBody | Request body. |
-> IO (OAuth2Result ByteString) | Response as ByteString |
Conduct post request.
AUTH requests
:: FromJSON a | |
=> Manager | HTTP connection manager. |
-> AccessToken | |
-> URI | Full URL |
-> IO (OAuth2Result a) | Response as JSON |
Conduct GET request and return response as JSON.
:: Manager | HTTP connection manager. |
-> AccessToken | |
-> URI | URL |
-> IO (OAuth2Result ByteString) | Response as ByteString |
Conduct GET request.
:: Manager | HTTP connection manager. |
-> AccessToken | |
-> URI | URL |
-> IO (OAuth2Result ByteString) | Response as ByteString |
same to authGetBS
but set access token to query parameter rather than header
:: FromJSON a | |
=> Manager | HTTP connection manager. |
-> AccessToken | |
-> URI | Full URL |
-> PostBody | |
-> IO (OAuth2Result a) | Response as JSON |
Conduct POST request and return response as JSON.
:: Manager | HTTP connection manager. |
-> AccessToken | |
-> URI | URL |
-> PostBody | |
-> IO (OAuth2Result ByteString) | Response as ByteString |
Conduct POST request.
:: Request | Request to perform |
-> (Request -> Request) | Modify request before sending |
-> Manager | HTTP connection manager. |
-> IO (OAuth2Result ByteString) |
Sends a HTTP request including the Authorization header with the specified access token.
Utilities
handleResponse :: Response ByteString -> OAuth2Result ByteString Source
Parses a Response
to to OAuth2Result
parseResponseJSON :: FromJSON a => OAuth2Result ByteString -> OAuth2Result a Source
Parses a OAuth2Result BSL.ByteString
into FromJSON a => a
updateRequestHeaders :: Maybe AccessToken -> Request -> Request Source
set several header values. + userAgennt : hoauth2 + accept : application/json + authorization : Bearer xxxxx if AccessToken provided.