Safe Haskell | None |
---|---|
Language | Haskell2010 |
Generic OAuth2 plugin for Yesod
See Yesod.Auth.OAuth2.GitHub
for example usage.
Synopsis
- data OAuth2 = OAuth2 {}
- type FetchCreds m = Manager -> OAuth2Token -> IO (Creds m)
- data Manager
- data OAuth2Token = OAuth2Token {}
- data Creds master = Creds {
- credsPlugin :: Text
- credsIdent :: Text
- credsExtra :: [(Text, Text)]
- oauth2Url :: Text -> AuthRoute
- authOAuth2 :: YesodAuth m => Text -> OAuth2 -> FetchCreds m -> AuthPlugin m
- authOAuth2Widget :: YesodAuth m => WidgetFor m () -> Text -> OAuth2 -> FetchCreds m -> AuthPlugin m
- getAccessToken :: Creds m -> Maybe AccessToken
- getRefreshToken :: Creds m -> Maybe RefreshToken
- getUserResponse :: Creds m -> Maybe ByteString
- getUserResponseJSON :: FromJSON a => Creds m -> Either String a
Documentation
Query Parameter Representation
type FetchCreds m = Manager -> OAuth2Token -> IO (Creds m) Source #
How to take an
and retrieve user credentialsOAuth2Token
Keeps track of open connections for keep-alive.
If possible, you should share a single Manager
between multiple threads and requests.
Since 0.1.0
Instances
HasHttpManager Manager | |
Defined in Network.HTTP.Client.Types getHttpManager :: Manager -> Manager # |
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
OAuth2Token | |
|
Instances
User credentials
Creds | |
|
authOAuth2 :: YesodAuth m => Text -> OAuth2 -> FetchCreds m -> AuthPlugin m Source #
Create an
for the given OAuth2 providerAuthPlugin
Presents a generic "Login via #{name}"
link
authOAuth2Widget :: YesodAuth m => WidgetFor m () -> Text -> OAuth2 -> FetchCreds m -> AuthPlugin m Source #
Create an
for the given OAuth2 providerAuthPlugin
Allows passing a custom widget for the login link. See
for an
example.oauth2Eve
Reading our credsExtra
keys
credsExtra
getAccessToken :: Creds m -> Maybe AccessToken Source #
Read the
from the values set via AccessToken
setExtra
getRefreshToken :: Creds m -> Maybe RefreshToken Source #
Read the
from the values set via RefreshToken
setExtra
N.B. not all providers supply this value.
getUserResponse :: Creds m -> Maybe ByteString Source #
Read the original profile response from the values set via setExtra
getUserResponseJSON :: FromJSON a => Creds m -> Either String a Source #
, and decode as JSONgetUserResponse