Safe Haskell | None |
---|---|
Language | Haskell2010 |
A simple OAuth2 Haskell binding. (This is supposed to be independent of the http client used.)
- data OAuth2 = OAuth2 {}
- newtype AccessToken = AccessToken {}
- newtype RefreshToken = RefreshToken {}
- newtype IdToken = IdToken {}
- newtype ExchangeToken = ExchangeToken {}
- data OAuth2Token = OAuth2Token {}
- data OAuth2Error a = OAuth2Error {}
- parseOAuth2Error :: FromJSON err => ByteString -> OAuth2Error err
- mkDecodeOAuth2Error :: ByteString -> String -> OAuth2Error err
- type OAuth2Result err a = Either (OAuth2Error err) a
- type PostBody = [(ByteString, ByteString)]
- type QueryParams = [(ByteString, ByteString)]
- authorizationUrl :: OAuth2 -> URI
- accessTokenUrl :: OAuth2 -> ExchangeToken -> (URI, PostBody)
- accessTokenUrl' :: OAuth2 -> ExchangeToken -> Maybe Text -> (URI, PostBody)
- refreshAccessTokenUrl :: OAuth2 -> RefreshToken -> (URI, PostBody)
- appendAccessToken :: URIRef a -> AccessToken -> URIRef a
- accessTokenToParam :: AccessToken -> [(ByteString, ByteString)]
- appendQueryParams :: [(ByteString, ByteString)] -> URIRef a -> URIRef a
- uriToRequest :: MonadThrow m => URI -> m Request
- requestToUri :: Request -> URI
- hostLens :: Lens' Request ByteString
- portLens :: Lens' Request Int
Data Types
Query Parameter Representation
newtype AccessToken Source #
newtype RefreshToken Source #
newtype ExchangeToken Source #
data OAuth2Token Source #
The gained Access Token. Use Data.Aeson.decode
to
decode string to AccessToken
. The refreshToken
is
special in some cases,
e.g. https://developers.google.com/accounts/docs/OAuth2
OAuth2Token | |
|
Show OAuth2Token Source # | |
Generic OAuth2Token Source # | |
ToJSON OAuth2Token Source # | |
FromJSON OAuth2Token Source # | Parse JSON data into |
type Rep OAuth2Token Source # | |
data OAuth2Error a Source #
Eq a => Eq (OAuth2Error a) Source # | |
Show a => Show (OAuth2Error a) Source # | |
Generic (OAuth2Error a) Source # | |
ToJSON err => ToJSON (OAuth2Error err) Source # | |
FromJSON err => FromJSON (OAuth2Error err) Source # | |
type Rep (OAuth2Error a) Source # | |
parseOAuth2Error :: FromJSON err => ByteString -> OAuth2Error err Source #
mkDecodeOAuth2Error :: ByteString -> String -> OAuth2Error err Source #
Types Synonym
type OAuth2Result err a = Either (OAuth2Error err) a Source #
type PostBody = [(ByteString, ByteString)] Source #
type synonym of post body content
type QueryParams = [(ByteString, ByteString)] Source #
URLs
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.
:: OAuth2 | |
-> ExchangeToken | access code gained via authorization URL |
-> Maybe Text | Grant Type |
-> (URI, PostBody) | access token request URL plus the request body. |
Prepare the URL and the request body query for fetching an access token, with optional grant type.
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.
:: URIRef a | Base URI |
-> AccessToken | Authorized Access Token |
-> URIRef a | Combined Result |
For GET
method API.
accessTokenToParam :: AccessToken -> [(ByteString, ByteString)] Source #
Create QueryParams
with given access token value.
appendQueryParams :: [(ByteString, ByteString)] -> URIRef a -> URIRef a Source #
uriToRequest :: MonadThrow m => URI -> m Request Source #
requestToUri :: Request -> URI Source #