Safe Haskell | None |
---|
A simple OAuth2 Haskell binding. (This is supposed to be independent with http client.)
- data OAuth2 = OAuth2 {}
- data OAuthException = OAuthException String
- data AccessToken = AccessToken {}
- type QueryParams = [(ByteString, ByteString)]
- type PostBody = [(ByteString, ByteString)]
- type URI = ByteString
- type AccessCode = ByteString
- authorizationUrl :: OAuth2 -> URI
- accessTokenUrl :: OAuth2 -> AccessCode -> (URI, PostBody)
- accessTokenUrl' :: OAuth2 -> AccessCode -> Maybe ByteString -> (URI, PostBody)
- refreshAccessTokenUrl :: OAuth2 -> ByteString -> (URI, PostBody)
- appendQueryParam :: URI -> QueryParams -> URI
- appendQueryParam' :: URI -> QueryParams -> URI
- appendAccessToken :: URI -> OAuth2 -> URI
- accessTokenToParam :: ByteString -> QueryParams
- transform' :: [(a, Maybe b)] -> [(a, b)]
Documentation
Query Parameter Representation
OAuth2 | |
|
data OAuthException Source
Simple Exception representation.
Eq OAuthException | |
Show OAuthException | |
Typeable OAuthException | |
Exception OAuthException | OAuthException is kind of Exception. |
data AccessToken Source
The gained Access Token. Use Data.Aeson.decode
to decode string to AccessToken
.
The refresheToken
is special at some case.
e.g. https:developers.google.comaccountsdocs/OAuth2
Show AccessToken | |
FromJSON AccessToken | Parse JSON data into {AccessToken} |
type QueryParams = [(ByteString, ByteString)]Source
type synonym of query parameters
type PostBody = [(ByteString, ByteString)]Source
type synonym of post body content
type URI = ByteStringSource
type synonym of a URI
type AccessCode = ByteStringSource
Access Code that is required for fetching Access Token
authorizationUrl :: OAuth2 -> URISource
Prepare the authorization URL. Redirect to this URL asking for user interactive authentication.
:: OAuth2 | |
-> AccessCode | access code gained via authorization URL |
-> (URI, PostBody) | access token request URL plus the request body. |
Prepare URL and the request body query for fetching access token.
:: OAuth2 | |
-> AccessCode | access code gained via authorization URL |
-> Maybe ByteString | Grant Type |
-> (URI, PostBody) | access token request URL plus the request body. |
:: OAuth2 | |
-> ByteString | 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.
appendQueryParam :: URI -> QueryParams -> URISource
Append query parameters with ?
appendQueryParam' :: URI -> QueryParams -> URISource
Append query parameters with &
.
For GET method API.
accessTokenToParam :: ByteString -> QueryParamsSource
Create QueryParams with given access token value.
transform' :: [(a, Maybe b)] -> [(a, b)]Source
lift value in the Maybe and abonda Nothing