Copyright | (c) 2012 Haisheng Wu |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Haisheng Wu <freizl@gmail.com> |
Stability | Beta |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
A lightweight oauth2 haskell binding.
Synopsis
- module Network.OAuth.OAuth2.HttpClient
- authorizationUrl :: OAuth2 -> URI
- 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
- module Network.OAuth.OAuth2.Internal
Documentation
authorizationUrl :: OAuth2 -> URI Source #
Prepare the authorization URL. Redirect to this URL asking for user interactive authentication.
:: 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 #
:: 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 |
:: (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`