| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Yesod.Auth.OAuth2
Description
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
- 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
Constructors
| OAuth2 | |
Fields | |
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 Methods 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
Constructors
| OAuth2Token | |
Fields
| |
Instances
User credentials
Constructors
| Creds | |
Fields
| |
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
Alternatives that use fetchAccessToken2
authOAuth2' :: YesodAuth m => Text -> OAuth2 -> FetchCreds m -> AuthPlugin m Source #
A version of authOAuth2 that uses fetchAccessToken2
See https://github.com/thoughtbot/yesod-auth-oauth2/pull/129
authOAuth2Widget' :: YesodAuth m => WidgetFor m () -> Text -> OAuth2 -> FetchCreds m -> AuthPlugin m Source #
A version of authOAuth2Widget that uses fetchAccessToken2
See https://github.com/thoughtbot/yesod-auth-oauth2/pull/129
Reading our credsExtra keys
credsExtragetAccessToken :: Creds m -> Maybe AccessToken Source #
Read the from the values set via AccessTokensetExtra
getRefreshToken :: Creds m -> Maybe RefreshToken Source #
Read the from the values set via RefreshTokensetExtra
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