hoauth2-2.2.0: Haskell OAuth2 authentication client
Safe HaskellNone
LanguageHaskell2010

Network.OAuth.OAuth2.HttpClient

Description

A simple http client to request OAuth2 tokens and several utils.

Synopsis

Token management

fetchAccessToken Source #

Arguments

:: 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

fetchAccessToken2 Source #

Arguments

:: Manager

HTTP connection manager

-> OAuth2

OAuth Data

-> ExchangeToken

OAuth 2 Tokens

-> ExceptT (OAuth2Error Errors) IO OAuth2Token

Access Token

Please read the docs of fetchAccessToken.

refreshAccessToken Source #

Arguments

:: 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

refreshAccessToken2 Source #

Arguments

:: Manager

HTTP connection manager.

-> OAuth2

OAuth context

-> RefreshToken

refresh token gained after authorization

-> ExceptT (OAuth2Error Errors) IO OAuth2Token 

Please read the docs of refreshAccessToken.

doSimplePostRequest Source #

Arguments

:: 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

authGetJSON Source #

Arguments

:: 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.

authGetBS Source #

Arguments

:: Manager

HTTP connection manager.

-> AccessToken 
-> URI 
-> ExceptT ByteString IO ByteString

Response as ByteString

Conduct an authorized GET request. Inject Access Token to Authorization Header.

authGetBS2 Source #

Arguments

:: 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

authPostJSON Source #

Arguments

:: 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.

authPostBS Source #

Arguments

:: 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.

authPostBS2 Source #

Arguments

:: 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.

authPostBS3 Source #

Arguments

:: 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

authRequest Source #

Arguments

:: 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.