hoauth2-2.5.0: Haskell OAuth2 authentication client
Safe HaskellNone
LanguageHaskell2010

Network.OAuth.OAuth2.TokenRequest

Synopsis

Token Request Errors

data Errors Source #

Instances

Instances details
Eq Errors Source # 
Instance details

Defined in Network.OAuth.OAuth2.TokenRequest

Methods

(==) :: Errors -> Errors -> Bool #

(/=) :: Errors -> Errors -> Bool #

Show Errors Source # 
Instance details

Defined in Network.OAuth.OAuth2.TokenRequest

Generic Errors Source # 
Instance details

Defined in Network.OAuth.OAuth2.TokenRequest

Associated Types

type Rep Errors :: Type -> Type #

Methods

from :: Errors -> Rep Errors x #

to :: Rep Errors x -> Errors #

ToJSON Errors Source # 
Instance details

Defined in Network.OAuth.OAuth2.TokenRequest

FromJSON Errors Source # 
Instance details

Defined in Network.OAuth.OAuth2.TokenRequest

type Rep Errors Source # 
Instance details

Defined in Network.OAuth.OAuth2.TokenRequest

type Rep Errors = D1 ('MetaData "Errors" "Network.OAuth.OAuth2.TokenRequest" "hoauth2-2.5.0-5oPHvsmGj3IL4g1W182tTw" 'False) ((C1 ('MetaCons "InvalidRequest" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "InvalidClient" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "InvalidGrant" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "UnauthorizedClient" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "UnsupportedGrantType" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "InvalidScope" 'PrefixI 'False) (U1 :: Type -> Type))))

URL

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.

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

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 

Utilies

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`