Safe Haskell | None |
---|---|
Language | Haskell2010 |
Network.OAuth.OAuth2.HttpClient
Contents
Description
A simple http client to request OAuth2 tokens and several utils.
Synopsis
- fetchAccessToken :: Manager -> OAuth2 -> ExchangeToken -> IO (OAuth2Result Errors OAuth2Token)
- fetchAccessToken2 :: Manager -> OAuth2 -> ExchangeToken -> IO (OAuth2Result Errors OAuth2Token)
- refreshAccessToken :: Manager -> OAuth2 -> RefreshToken -> IO (OAuth2Result Errors OAuth2Token)
- refreshAccessToken2 :: Manager -> OAuth2 -> RefreshToken -> IO (OAuth2Result Errors OAuth2Token)
- authGetJSON :: FromJSON b => Manager -> AccessToken -> URI -> IO (Either ByteString b)
- authGetBS :: Manager -> AccessToken -> URI -> IO (Either ByteString ByteString)
- authGetBS2 :: Manager -> AccessToken -> URI -> IO (Either ByteString ByteString)
- authPostJSON :: FromJSON b => Manager -> AccessToken -> URI -> PostBody -> IO (Either ByteString b)
- authPostBS :: Manager -> AccessToken -> URI -> PostBody -> IO (Either ByteString ByteString)
- authPostBS2 :: Manager -> AccessToken -> URI -> PostBody -> IO (Either ByteString ByteString)
- authPostBS3 :: Manager -> AccessToken -> URI -> IO (Either ByteString ByteString)
- authRequest :: Request -> (Request -> Request) -> Manager -> IO (Either ByteString ByteString)
Token management
Arguments
:: Manager | HTTP connection manager |
-> OAuth2 | OAuth Data |
-> ExchangeToken | OAuth2 Code |
-> IO (OAuth2Result Errors OAuth2Token) | Access Token |
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
Arguments
:: Manager | HTTP connection manager |
-> OAuth2 | OAuth Data |
-> ExchangeToken | OAuth 2 Tokens |
-> IO (OAuth2Result Errors OAuth2Token) | Access Token |
Please read the docs of fetchAccessToken
.
Arguments
:: Manager | HTTP connection manager. |
-> OAuth2 | OAuth context |
-> RefreshToken | refresh token gained after authorization |
-> IO (OAuth2Result Errors 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
Arguments
:: Manager | HTTP connection manager. |
-> OAuth2 | OAuth context |
-> RefreshToken | refresh token gained after authorization |
-> IO (OAuth2Result Errors OAuth2Token) |
Please read the docs of refreshAccessToken
.
AUTH requests
Arguments
:: FromJSON b | |
=> Manager | HTTP connection manager. |
-> AccessToken | |
-> URI | |
-> IO (Either ByteString b) | Response as JSON |
Conduct an authorized GET request and return response as JSON.
Arguments
:: Manager | HTTP connection manager. |
-> AccessToken | |
-> URI | |
-> IO (Either ByteString ByteString) | Response as ByteString |
Conduct an authorized GET request.
Arguments
:: Manager | HTTP connection manager. |
-> AccessToken | |
-> URI | |
-> IO (Either ByteString ByteString) | Response as ByteString |
same to authGetBS
but set access token to query parameter rather than header
Arguments
:: FromJSON b | |
=> Manager | HTTP connection manager. |
-> AccessToken | |
-> URI | |
-> PostBody | |
-> IO (Either ByteString b) | Response as JSON |
Conduct POST request and return response as JSON.
Arguments
:: Manager | HTTP connection manager. |
-> AccessToken | |
-> URI | |
-> PostBody | |
-> IO (Either ByteString ByteString) | Response as ByteString |
Conduct POST request.
Arguments
:: Manager | HTTP connection manager. |
-> AccessToken | |
-> URI | |
-> PostBody | |
-> IO (Either ByteString ByteString) | Response as ByteString |
Conduct POST request with access token in the request body rather header
Arguments
:: Manager | HTTP connection manager. |
-> AccessToken | |
-> URI | |
-> IO (Either ByteString ByteString) | Response as ByteString |
Conduct POST request with access token in the header and null in body
Arguments
:: Request | Request to perform |
-> (Request -> Request) | Modify request before sending |
-> Manager | HTTP connection manager. |
-> IO (Either ByteString ByteString) |
Send an HTTP request including the Authorization header with the specified access token.