Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Errors
- accessTokenUrl :: OAuth2 -> ExchangeToken -> (URI, PostBody)
- refreshAccessTokenUrl :: OAuth2 -> RefreshToken -> (URI, PostBody)
- clientSecretPost :: OAuth2 -> PostBody
- fetchAccessToken :: Manager -> OAuth2 -> ExchangeToken -> ExceptT (OAuth2Error Errors) IO OAuth2Token
- fetchAccessToken2 :: Manager -> OAuth2 -> ExchangeToken -> ExceptT (OAuth2Error Errors) IO OAuth2Token
- fetchAccessTokenInternal :: ClientAuthenticationMethod -> Manager -> OAuth2 -> ExchangeToken -> ExceptT (OAuth2Error Errors) IO OAuth2Token
- refreshAccessToken :: Manager -> OAuth2 -> RefreshToken -> ExceptT (OAuth2Error Errors) IO OAuth2Token
- refreshAccessToken2 :: Manager -> OAuth2 -> RefreshToken -> ExceptT (OAuth2Error Errors) IO OAuth2Token
- refreshAccessTokenInternal :: ClientAuthenticationMethod -> Manager -> OAuth2 -> RefreshToken -> ExceptT (OAuth2Error Errors) IO OAuth2Token
- doJSONPostRequest :: (FromJSON err, FromJSON a) => Manager -> OAuth2 -> URI -> PostBody -> ExceptT (OAuth2Error err) IO a
- doSimplePostRequest :: FromJSON err => Manager -> OAuth2 -> URI -> PostBody -> ExceptT (OAuth2Error err) IO ByteString
- handleOAuth2TokenResponse :: FromJSON err => Response ByteString -> Either (OAuth2Error err) ByteString
- parseResponseFlexible :: (FromJSON err, FromJSON a) => ByteString -> Either (OAuth2Error err) a
- parseResponseString :: (FromJSON err, FromJSON a) => ByteString -> Either (OAuth2Error err) a
- addDefaultRequestHeaders :: Request -> Request
Token Request Errors
Token Error Responses https://tools.ietf.org/html/rfc6749#section-5.2
Instances
Eq Errors Source # | |
Show Errors Source # | |
Generic Errors Source # | |
ToJSON Errors Source # | |
Defined in Network.OAuth.OAuth2.TokenRequest | |
FromJSON Errors Source # | |
type Rep Errors Source # | |
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
:: 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 #
:: 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.
clientSecretPost :: OAuth2 -> PostBody Source #
Token management
:: 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
:: Manager | HTTP connection manager |
-> OAuth2 | OAuth Data |
-> ExchangeToken | OAuth 2 Tokens |
-> ExceptT (OAuth2Error Errors) IO OAuth2Token | Access Token |
Deprecated: renamed to fetchAccessTokenInternal
fetchAccessTokenInternal Source #
:: ClientAuthenticationMethod | |
-> Manager | HTTP connection manager |
-> OAuth2 | OAuth Data |
-> ExchangeToken | OAuth 2 Tokens |
-> ExceptT (OAuth2Error Errors) IO OAuth2Token | Access Token |
:: 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
:: Manager | HTTP connection manager. |
-> OAuth2 | OAuth context |
-> RefreshToken | refresh token gained after authorization |
-> ExceptT (OAuth2Error Errors) IO OAuth2Token |
Deprecated: renamed to fetchAccessTokenInternal
refreshAccessTokenInternal Source #
:: ClientAuthenticationMethod | |
-> Manager | HTTP connection manager. |
-> OAuth2 | OAuth context |
-> RefreshToken | refresh token gained after authorization |
-> ExceptT (OAuth2Error Errors) IO OAuth2Token |
Utilies
:: (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.
:: 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`