Safe Haskell | None |
---|---|
Language | Haskell2010 |
Network.OAuth.OAuth2.Internal
Contents
Description
A simple OAuth2 Haskell binding. (This is supposed to be independent of the http client used.)
- data OAuth2 = OAuth2 {
- oauthClientId :: Text
- oauthClientSecret :: Text
- oauthOAuthorizeEndpoint :: URI
- oauthAccessTokenEndpoint :: URI
- oauthCallback :: Maybe URI
- newtype AccessToken = AccessToken {
- atoken :: Text
- newtype RefreshToken = RefreshToken {
- rtoken :: Text
- newtype IdToken = IdToken {
- idtoken :: Text
- newtype ExchangeToken = ExchangeToken {
- extoken :: Text
- data OAuth2Token = OAuth2Token {
- accessToken :: AccessToken
- refreshToken :: Maybe RefreshToken
- expiresIn :: Maybe Int
- tokenType :: Maybe Text
- idToken :: Maybe IdToken
- data OAuth2Error a = OAuth2Error {}
- parseOAuth2Error :: FromJSON err => ByteString -> 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
Constructors
OAuth2 | |
Fields
|
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
Constructors
OAuth2Token | |
Fields
|
Instances
Show OAuth2Token Source # | |
Generic OAuth2Token Source # | |
ToJSON OAuth2Token Source # | |
FromJSON OAuth2Token Source # | Parse JSON data into |
type Rep OAuth2Token Source # | |
data OAuth2Error a Source #
Constructors
OAuth2Error | |
Instances
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 #
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.
Arguments
:: 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.
Arguments
:: 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 #
Arguments
:: 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.
Arguments
:: 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 #