hoauth2-1.1.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

OAuth 2 Tokens

-> IO (OAuth2Result OAuth2Token)

Access Token

Request (via POST method) "OAuth2 Token".

fetchRefreshToken Source #

Arguments

:: Manager

HTTP connection manager.

-> OAuth2

OAuth context

-> RefreshToken

refresh token gained after authorization

-> IO (OAuth2Result AccessToken) 

Request the "Refresh Token".

doJSONPostRequest Source #

Arguments

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

doFlexiblePostRequest Source #

Arguments

:: 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 or Query String.

doSimplePostRequest Source #

Arguments

:: Manager

HTTP connection manager.

-> OAuth2

OAuth options

-> URI

URL

-> PostBody

Request body.

-> IO (OAuth2Result ByteString)

Response as ByteString

Conduct post request.

AUTH requests

authGetJSON Source #

Arguments

:: FromJSON a 
=> Manager

HTTP connection manager.

-> AccessToken 
-> URI

Full URL

-> IO (OAuth2Result a)

Response as JSON

Conduct GET request and return response as JSON.

authGetBS Source #

Arguments

:: Manager

HTTP connection manager.

-> AccessToken 
-> URI

URL

-> IO (OAuth2Result ByteString)

Response as ByteString

Conduct GET request.

authGetBS' Source #

Arguments

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

authPostJSON Source #

Arguments

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

authPostBS Source #

Arguments

:: Manager

HTTP connection manager.

-> AccessToken 
-> URI

URL

-> PostBody 
-> IO (OAuth2Result ByteString)

Response as ByteString

Conduct POST request.

authPostBS' Source #

Arguments

:: Manager

HTTP connection manager.

-> AccessToken 
-> URI

URL

-> PostBody 
-> IO (OAuth2Result ByteString)

Response as ByteString

Conduct POST request with access token in the request body rather header

authRequest Source #

Arguments

:: Request

Request to perform

-> (Request -> Request)

Modify request before sending

-> Manager

HTTP connection manager.

-> IO (OAuth2Result ByteString) 

Send an 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.

setMethod :: StdMethod -> Request -> Request Source #

Set the HTTP method to use.