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