hoauth2-2.3.0: Haskell OAuth2 authentication client
Copyright(c) 2012 Haisheng Wu
LicenseBSD-style (see the file LICENSE)
MaintainerHaisheng Wu <freizl@gmail.com>
StabilityBeta
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Network.OAuth.OAuth2

Description

A lightweight oauth2 haskell binding.

Synopsis

Documentation

authorizationUrl :: OAuth2 -> URI Source #

Prepare the authorization URL. Redirect to this URL asking for user interactive authentication.

accessTokenUrl Source #

Arguments

:: OAuth2 
-> ExchangeToken

access code gained via authorization URL

-> (URI, PostBody)

access token request URL plus the request body.

Prepare the URL and the request body query for fetching an access token.

refreshAccessTokenUrl Source #

Arguments

:: OAuth2 
-> RefreshToken

refresh token gained via authorization URL

-> (URI, PostBody)

refresh token request URL plus the request body.

Using a Refresh Token. Obtain a new access token by sending a refresh token to the Authorization server.

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

Deprecated: renamed to fetchAccessTokenInternal

fetchAccessTokenInternal Source #

Arguments

:: ClientAuthenticationMethod 
-> Manager

HTTP connection manager

-> OAuth2

OAuth Data

-> ExchangeToken

OAuth 2 Tokens

-> ExceptT (OAuth2Error Errors) IO OAuth2Token

Access Token

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 

Deprecated: renamed to fetchAccessTokenInternal

refreshAccessTokenInternal Source #

Arguments

:: ClientAuthenticationMethod 
-> Manager

HTTP connection manager.

-> OAuth2

OAuth context

-> RefreshToken

refresh token gained after authorization

-> ExceptT (OAuth2Error Errors) IO OAuth2Token 

doJSONPostRequest Source #

Arguments

:: (FromJSON err, FromJSON a) 
=> Manager

HTTP connection manager.

-> OAuth2

OAuth options

-> URI

The URL

-> PostBody

request body

-> ExceptT (OAuth2Error err) IO a

Response as JSON

Conduct post request and return response as JSON.

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.

handleOAuth2TokenResponse :: FromJSON err => Response ByteString -> Either (OAuth2Error err) ByteString Source #

Parses a Response to to OAuth2Result

parseResponseFlexible :: (FromJSON err, FromJSON a) => ByteString -> Either (OAuth2Error err) a Source #

Try parseResponseJSON, if failed then parses the OAuth2Result BSL.ByteString that contains not JSON but a Query String.

parseResponseString :: (FromJSON err, FromJSON a) => ByteString -> Either (OAuth2Error err) a Source #

Parses a OAuth2Result BSL.ByteString that contains not JSON but a Query String

addDefaultRequestHeaders :: Request -> Request Source #

Set several header values: + userAgennt : hoauth2 + accept : `application/json`