Safe Haskell | None |
---|---|
Language | Haskell2010 |
Network.OAuth.OAuth2.Compat
Synopsis
- data OAuth2 = OAuth2 {}
- authorizationUrl :: OAuth2 -> URI
- fetchAccessToken :: Manager -> OAuth2 -> ExchangeToken -> IO (OAuth2Result Errors OAuth2Token)
- fetchAccessToken2 :: Manager -> OAuth2 -> ExchangeToken -> IO (OAuth2Result Errors OAuth2Token)
- authRequest :: Request -> (Request -> Request) -> Manager -> IO (Either ByteString ByteString)
- authPostBS3 :: Manager -> AccessToken -> URI -> IO (Either ByteString ByteString)
- authPostBS2 :: Manager -> AccessToken -> URI -> PostBody -> IO (Either ByteString ByteString)
- authPostBS :: Manager -> AccessToken -> URI -> PostBody -> IO (Either ByteString ByteString)
- authPostJSON :: FromJSON b => Manager -> AccessToken -> URI -> PostBody -> IO (Either ByteString b)
- authGetBS2 :: Manager -> AccessToken -> URI -> IO (Either ByteString ByteString)
- authGetBS :: Manager -> AccessToken -> URI -> IO (Either ByteString ByteString)
- authGetJSON :: FromJSON b => Manager -> AccessToken -> URI -> IO (Either ByteString b)
- doSimplePostRequest :: FromJSON err => Manager -> OAuth2 -> URI -> PostBody -> IO (OAuth2Result err ByteString)
- refreshAccessToken2 :: Manager -> OAuth2 -> RefreshToken -> IO (OAuth2Result Errors OAuth2Token)
- refreshAccessToken :: Manager -> OAuth2 -> RefreshToken -> IO (OAuth2Result Errors OAuth2Token)
- portLens :: Lens' Request Int
- hostLens :: Lens' Request ByteString
- requestToUri :: Request -> URI
- uriToRequest :: MonadThrow m => URI -> m Request
- appendQueryParams :: [(ByteString, ByteString)] -> URIRef a -> URIRef a
- accessTokenToParam :: AccessToken -> [(ByteString, ByteString)]
- appendAccessToken :: URIRef a -> AccessToken -> URIRef a
- refreshAccessTokenUrl :: OAuth2 -> RefreshToken -> (URI, PostBody)
- accessTokenUrl' :: OAuth2 -> ExchangeToken -> Maybe Text -> (URI, PostBody)
- accessTokenUrl :: OAuth2 -> ExchangeToken -> (URI, PostBody)
- mkDecodeOAuth2Error :: ByteString -> String -> OAuth2Error err
- parseOAuth2Error :: FromJSON err => ByteString -> OAuth2Error err
- parseIntFlexible :: Value -> Parser Int
- data OAuth2 = OAuth2 {}
- newtype AccessToken = AccessToken {}
- newtype RefreshToken = RefreshToken {}
- newtype IdToken = IdToken {}
- newtype ExchangeToken = ExchangeToken {}
- data OAuth2Token = OAuth2Token {}
- data OAuth2Error a = OAuth2Error {}
- type OAuth2Result err a = Either (OAuth2Error err) a
- type PostBody = [(ByteString, ByteString)]
- type QueryParams = [(ByteString, ByteString)]
Documentation
Query Parameter Representation TODO: fix typo in OAuthorizeEndpoint rename AccessToken to TokenEndpoint rename callback to redirectUri
Constructors
OAuth2 | |
authorizationUrl :: OAuth2 -> URI Source #
fetchAccessToken :: Manager -> OAuth2 -> ExchangeToken -> IO (OAuth2Result Errors OAuth2Token) Source #
fetchAccessToken2 :: Manager -> OAuth2 -> ExchangeToken -> IO (OAuth2Result Errors OAuth2Token) Source #
Arguments
:: Request | Request to perform |
-> (Request -> Request) | Modify request before sending |
-> Manager | HTTP connection manager. |
-> IO (Either ByteString ByteString) |
Send an HTTP request including the Authorization header with the specified access token.
Arguments
:: Manager | HTTP connection manager. |
-> AccessToken | |
-> URI | |
-> IO (Either ByteString ByteString) | Response as ByteString |
Conduct POST request with access token in the header and null in body
Arguments
:: Manager | HTTP connection manager. |
-> AccessToken | |
-> URI | |
-> PostBody | |
-> IO (Either ByteString ByteString) | Response as ByteString |
Conduct POST request with access token in the request body rather header
Arguments
:: Manager | HTTP connection manager. |
-> AccessToken | |
-> URI | |
-> PostBody | |
-> IO (Either ByteString ByteString) | Response as ByteString |
Conduct POST request.
Arguments
:: FromJSON b | |
=> Manager | HTTP connection manager. |
-> AccessToken | |
-> URI | |
-> PostBody | |
-> IO (Either ByteString b) | Response as JSON |
Conduct POST request and return response as JSON.
Arguments
:: Manager | HTTP connection manager. |
-> AccessToken | |
-> URI | |
-> IO (Either ByteString ByteString) | Response as ByteString |
same to authGetBS
but set access token to query parameter rather than header
Arguments
:: Manager | HTTP connection manager. |
-> AccessToken | |
-> URI | |
-> IO (Either ByteString ByteString) | Response as ByteString |
Conduct an authorized GET request.
Arguments
:: FromJSON b | |
=> Manager | HTTP connection manager. |
-> AccessToken | |
-> URI | |
-> IO (Either ByteString b) | Response as JSON |
Conduct an authorized GET request and return response as JSON.
Arguments
:: FromJSON err | |
=> Manager | HTTP connection manager. |
-> OAuth2 | OAuth options |
-> URI | URL |
-> PostBody | Request body. |
-> IO (OAuth2Result err ByteString) | Response as ByteString |
Conduct post request.
Arguments
:: Manager | HTTP connection manager. |
-> OAuth2 | OAuth context |
-> RefreshToken | refresh token gained after authorization |
-> IO (OAuth2Result Errors OAuth2Token) |
Please read the docs of refreshAccessToken
.
Arguments
:: Manager | HTTP connection manager. |
-> OAuth2 | OAuth context |
-> RefreshToken | refresh token gained after authorization |
-> IO (OAuth2Result Errors 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
requestToUri :: Request -> URI #
uriToRequest :: MonadThrow m => URI -> m Request #
appendQueryParams :: [(ByteString, ByteString)] -> URIRef a -> URIRef a #
accessTokenToParam :: AccessToken -> [(ByteString, ByteString)] #
Create QueryParams
with given access token value.
Arguments
:: URIRef a | Base URI |
-> AccessToken | Authorized Access Token |
-> URIRef a | Combined Result |
For GET
method API.
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
:: 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.
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.
mkDecodeOAuth2Error :: ByteString -> String -> OAuth2Error err #
parseOAuth2Error :: FromJSON err => ByteString -> OAuth2Error err #
parseIntFlexible :: Value -> Parser Int #
Query Parameter Representation TODO: fix typo in OAuthorizeEndpoint rename AccessToken to TokenEndpoint rename callback to redirectUri
Constructors
OAuth2 | |
newtype AccessToken #
Constructors
AccessToken | |
Instances
Eq AccessToken | |
Defined in Network.OAuth.OAuth2.Internal | |
Show AccessToken | |
Defined in Network.OAuth.OAuth2.Internal Methods showsPrec :: Int -> AccessToken -> ShowS # show :: AccessToken -> String # showList :: [AccessToken] -> ShowS # | |
ToJSON AccessToken | |
Defined in Network.OAuth.OAuth2.Internal Methods toJSON :: AccessToken -> Value # toEncoding :: AccessToken -> Encoding # toJSONList :: [AccessToken] -> Value # toEncodingList :: [AccessToken] -> Encoding # | |
FromJSON AccessToken | |
Defined in Network.OAuth.OAuth2.Internal | |
Binary AccessToken | |
Defined in Network.OAuth.OAuth2.Internal |
newtype RefreshToken #
Constructors
RefreshToken | |
Instances
Eq RefreshToken | |
Defined in Network.OAuth.OAuth2.Internal | |
Show RefreshToken | |
Defined in Network.OAuth.OAuth2.Internal Methods showsPrec :: Int -> RefreshToken -> ShowS # show :: RefreshToken -> String # showList :: [RefreshToken] -> ShowS # | |
ToJSON RefreshToken | |
Defined in Network.OAuth.OAuth2.Internal Methods toJSON :: RefreshToken -> Value # toEncoding :: RefreshToken -> Encoding # toJSONList :: [RefreshToken] -> Value # toEncodingList :: [RefreshToken] -> Encoding # | |
FromJSON RefreshToken | |
Defined in Network.OAuth.OAuth2.Internal | |
Binary RefreshToken | |
Defined in Network.OAuth.OAuth2.Internal |
newtype ExchangeToken #
Constructors
ExchangeToken | |
Instances
Show ExchangeToken | |
Defined in Network.OAuth.OAuth2.Internal Methods showsPrec :: Int -> ExchangeToken -> ShowS # show :: ExchangeToken -> String # showList :: [ExchangeToken] -> ShowS # | |
ToJSON ExchangeToken | |
Defined in Network.OAuth.OAuth2.Internal Methods toJSON :: ExchangeToken -> Value # toEncoding :: ExchangeToken -> Encoding # toJSONList :: [ExchangeToken] -> Value # toEncodingList :: [ExchangeToken] -> Encoding # | |
FromJSON ExchangeToken | |
Defined in Network.OAuth.OAuth2.Internal Methods parseJSON :: Value -> Parser ExchangeToken # parseJSONList :: Value -> Parser [ExchangeToken] # |
data OAuth2Token #
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
data OAuth2Error a #
Constructors
OAuth2Error | |
Instances
type OAuth2Result err a = Either (OAuth2Error err) a #
type PostBody = [(ByteString, ByteString)] #
type synonym of post body content
type QueryParams = [(ByteString, ByteString)] #