Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A lightweight oauth2 Haskell binding. See Readme for more details
Synopsis
- module Network.OAuth.OAuth2.HttpClient
- authorizationUrl :: OAuth2 -> URI
- authorizationUrlWithParams :: QueryParams -> OAuth2 -> URI
- accessTokenUrl :: OAuth2 -> ExchangeToken -> (URI, PostBody)
- refreshAccessTokenUrl :: OAuth2 -> RefreshToken -> (URI, PostBody)
- fetchAccessToken :: MonadIO m => Manager -> OAuth2 -> ExchangeToken -> ExceptT (OAuth2Error Errors) m OAuth2Token
- fetchAccessToken2 :: MonadIO m => Manager -> OAuth2 -> ExchangeToken -> ExceptT (OAuth2Error Errors) m OAuth2Token
- fetchAccessTokenInternal :: MonadIO m => ClientAuthenticationMethod -> Manager -> OAuth2 -> ExchangeToken -> ExceptT (OAuth2Error Errors) m OAuth2Token
- fetchAccessTokenWithAuthMethod :: MonadIO m => ClientAuthenticationMethod -> Manager -> OAuth2 -> ExchangeToken -> ExceptT (OAuth2Error Errors) m OAuth2Token
- refreshAccessToken :: MonadIO m => Manager -> OAuth2 -> RefreshToken -> ExceptT (OAuth2Error Errors) m OAuth2Token
- refreshAccessToken2 :: MonadIO m => Manager -> OAuth2 -> RefreshToken -> ExceptT (OAuth2Error Errors) m OAuth2Token
- refreshAccessTokenInternal :: MonadIO m => ClientAuthenticationMethod -> Manager -> OAuth2 -> RefreshToken -> ExceptT (OAuth2Error Errors) m OAuth2Token
- refreshAccessTokenWithAuthMethod :: MonadIO m => ClientAuthenticationMethod -> Manager -> OAuth2 -> RefreshToken -> ExceptT (OAuth2Error Errors) m OAuth2Token
- doJSONPostRequest :: (MonadIO m, FromJSON err, FromJSON a) => Manager -> OAuth2 -> URI -> PostBody -> ExceptT (OAuth2Error err) m a
- doSimplePostRequest :: (MonadIO m, FromJSON err) => Manager -> OAuth2 -> URI -> PostBody -> ExceptT (OAuth2Error err) m 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
- clientSecretPost :: OAuth2 -> PostBody
- module Network.OAuth.OAuth2.Internal
Documentation
authorizationUrlWithParams :: QueryParams -> OAuth2 -> URI Source #
Prepare the authorization URL. Redirect to this URL asking for user interactive authentication.
Since: 2.6.0
:: 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. |
Obtain a new access token by sending a Refresh Token to the Authorization server.
:: MonadIO m | |
=> Manager | HTTP connection manager |
-> OAuth2 | OAuth Data |
-> ExchangeToken | OAuth2 Code |
-> ExceptT (OAuth2Error Errors) m OAuth2Token | Access Token |
Exchange code
for an Access Token with authenticate in request header.
:: MonadIO m | |
=> Manager | HTTP connection manager |
-> OAuth2 | OAuth Data |
-> ExchangeToken | Authorization Code |
-> ExceptT (OAuth2Error Errors) m OAuth2Token | Access Token |
Deprecated: use fetchAccessTokenWithAuthMethod
fetchAccessTokenInternal Source #
:: MonadIO m | |
=> ClientAuthenticationMethod | |
-> Manager | HTTP connection manager |
-> OAuth2 | OAuth Data |
-> ExchangeToken | Authorization Code |
-> ExceptT (OAuth2Error Errors) m OAuth2Token | Access Token |
Deprecated: use fetchAccessTokenWithAuthMethod
fetchAccessTokenWithAuthMethod Source #
:: MonadIO m | |
=> ClientAuthenticationMethod | |
-> Manager | HTTP connection manager |
-> OAuth2 | OAuth Data |
-> ExchangeToken | Authorization Code |
-> ExceptT (OAuth2Error Errors) m OAuth2Token | Access Token |
Exchange code
for an Access Token
OAuth2 spec allows credential (client_id
, client_secret
) to be sent
either in the header (a.k.a ClientSecretBasic
).
or as form/url params (a.k.a ClientSecretPost
).
The OAuth provider can choose to implement only one, or both.
Look for API document from the OAuth provider you're dealing with.
If you're uncertain, try fetchAccessToken
which sends credential
in authorization http header, which is common case.
Since: 2.6.0
:: MonadIO m | |
=> Manager | HTTP connection manager. |
-> OAuth2 | OAuth context |
-> RefreshToken | Refresh Token gained after authorization |
-> ExceptT (OAuth2Error Errors) m OAuth2Token |
Fetch a new AccessToken using the Refresh Token with authentication in request header.
:: MonadIO m | |
=> Manager | HTTP connection manager. |
-> OAuth2 | OAuth context |
-> RefreshToken | Refresh Token gained after authorization |
-> ExceptT (OAuth2Error Errors) m OAuth2Token |
Deprecated: use refreshAccessTokenWithAuthMethod
refreshAccessTokenInternal Source #
:: MonadIO m | |
=> ClientAuthenticationMethod | |
-> Manager | HTTP connection manager. |
-> OAuth2 | OAuth context |
-> RefreshToken | Refresh Token gained after authorization |
-> ExceptT (OAuth2Error Errors) m OAuth2Token |
Deprecated: use refreshAccessTokenWithAuthMethod
refreshAccessTokenWithAuthMethod Source #
:: MonadIO m | |
=> ClientAuthenticationMethod | |
-> Manager | HTTP connection manager. |
-> OAuth2 | OAuth context |
-> RefreshToken | Refresh Token gained after authorization |
-> ExceptT (OAuth2Error Errors) m OAuth2Token |
Fetch a new AccessToken using the Refresh Token.
OAuth2 spec allows credential (client_id
, client_secret
) to be sent
either in the header (a.k.a ClientSecretBasic
).
or as form/url params (a.k.a ClientSecretPost
).
The OAuth provider can choose to implement only one, or both.
Look for API document from the OAuth provider you're dealing with.
If you're uncertain, try refreshAccessToken
which sends credential
in authorization http header, which is common case.
Since: 2.6.0
:: (MonadIO m, FromJSON err, FromJSON a) | |
=> Manager | HTTP connection manager. |
-> OAuth2 | OAuth options |
-> URI | The URL |
-> PostBody | request body |
-> ExceptT (OAuth2Error err) m a | Response as JSON |
Conduct post request and return response as JSON.
:: (MonadIO m, FromJSON err) | |
=> Manager | HTTP connection manager. |
-> OAuth2 | OAuth options |
-> URI | URL |
-> PostBody | Request body. |
-> ExceptT (OAuth2Error err) m ByteString | Response as ByteString |
Conduct post request.
handleOAuth2TokenResponse :: FromJSON err => Response ByteString -> Either (OAuth2Error err) ByteString Source #
Gets response body from a Response
if 200 otherwise assume OAuth2Error
parseResponseFlexible :: (FromJSON err, FromJSON a) => ByteString -> Either (OAuth2Error err) a Source #
Try to parses response as JSON, if failed, try to parse as like query string.
parseResponseString :: (FromJSON err, FromJSON a) => ByteString -> Either (OAuth2Error err) a Source #
Parses the response that contains not JSON but a Query String
addDefaultRequestHeaders :: Request -> Request Source #
Set several header values:
+ userAgennt : hoauth2
+ accept : `application/json`
clientSecretPost :: OAuth2 -> PostBody Source #
Add Credential (client_id, client_secret) to the request post body.