hoauth2-1.15.0: Haskell OAuth2 authentication client

Safe HaskellNone
LanguageHaskell2010

Network.OAuth.OAuth2.HttpClient

Contents

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

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

fetchAccessToken2 Source #

Arguments

:: Manager

HTTP connection manager

-> OAuth2

OAuth Data

-> ExchangeToken

OAuth 2 Tokens

-> IO (OAuth2Result Errors 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

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

refreshAccessToken2 Source #

Arguments

:: Manager

HTTP connection manager.

-> OAuth2

OAuth context

-> RefreshToken

refresh token gained after authorization

-> IO (OAuth2Result Errors OAuth2Token) 

Please read the docs of refreshAccessToken.

doSimplePostRequest Source #

Arguments

:: FromJSON err 
=> Manager

HTTP connection manager.

-> OAuth2

OAuth options

-> URI

URL

-> PostBody

Request body.

-> IO (OAuth2Result err ByteString)

Response as ByteString

Conduct post request.

AUTH requests

authGetJSON Source #

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.

authGetBS Source #

Arguments

:: Manager

HTTP connection manager.

-> AccessToken 
-> URI 
-> IO (Either ByteString ByteString)

Response as ByteString

Conduct an authorized GET request.

authGetBS2 Source #

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

authPostJSON Source #

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.

authPostBS Source #

Arguments

:: Manager

HTTP connection manager.

-> AccessToken 
-> URI 
-> PostBody 
-> IO (Either ByteString ByteString)

Response as ByteString

Conduct POST request.

authPostBS2 Source #

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

authPostBS3 Source #

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

authRequest Source #

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.