mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-08-29 16:03:50 +02:00
Tweak whitespace and alignment
This commit is contained in:
parent
c54b2c7ba1
commit
6e904f1be3
@ -44,9 +44,9 @@ import qualified Data.Text as T
|
|||||||
-- identifier.
|
-- identifier.
|
||||||
--
|
--
|
||||||
oauth2Google :: YesodAuth m
|
oauth2Google :: YesodAuth m
|
||||||
=> Text -- ^ Client ID
|
=> Text -- ^ Client ID
|
||||||
-> Text -- ^ Client Secret
|
-> Text -- ^ Client Secret
|
||||||
-> AuthPlugin m
|
-> AuthPlugin m
|
||||||
oauth2Google = oauth2GoogleScoped ["openid", "email"]
|
oauth2Google = oauth2GoogleScoped ["openid", "email"]
|
||||||
|
|
||||||
-- | Auth with Google
|
-- | Auth with Google
|
||||||
@ -54,10 +54,10 @@ oauth2Google = oauth2GoogleScoped ["openid", "email"]
|
|||||||
-- Requests custom scopes and uses email as the @'Creds'@ identifier.
|
-- Requests custom scopes and uses email as the @'Creds'@ identifier.
|
||||||
--
|
--
|
||||||
oauth2GoogleScoped :: YesodAuth m
|
oauth2GoogleScoped :: YesodAuth m
|
||||||
=> [Text] -- ^ List of scopes to request
|
=> [Text] -- ^ List of scopes to request
|
||||||
-> Text -- ^ Client ID
|
-> Text -- ^ Client ID
|
||||||
-> Text -- ^ Client Secret
|
-> Text -- ^ Client Secret
|
||||||
-> AuthPlugin m
|
-> AuthPlugin m
|
||||||
oauth2GoogleScoped = oauth2GoogleScopedWithCustomId emailUid
|
oauth2GoogleScoped = oauth2GoogleScopedWithCustomId emailUid
|
||||||
|
|
||||||
-- | Auth with Google
|
-- | Auth with Google
|
||||||
@ -68,23 +68,24 @@ oauth2GoogleScoped = oauth2GoogleScopedWithCustomId emailUid
|
|||||||
-- See @'emailUid'@ and @'googleUid'@.
|
-- See @'emailUid'@ and @'googleUid'@.
|
||||||
--
|
--
|
||||||
oauth2GoogleScopedWithCustomId :: YesodAuth m
|
oauth2GoogleScopedWithCustomId :: YesodAuth m
|
||||||
=> (GoogleUser -> AccessToken -> Creds m) -- ^ A function to generate the credentials
|
=> (GoogleUser -> AccessToken -> Creds m)
|
||||||
-> [Text] -- ^ List of scopes to request
|
-- ^ A function to generate the credentials
|
||||||
-> Text -- ^ Client ID
|
-> [Text] -- ^ List of scopes to request
|
||||||
-> Text -- ^ Client secret
|
-> Text -- ^ Client ID
|
||||||
-> AuthPlugin m
|
-> Text -- ^ Client secret
|
||||||
oauth2GoogleScopedWithCustomId toCreds scopes clientId clientSecret = authOAuth2 "google" oauth $ fetchGoogleProfile toCreds
|
-> AuthPlugin m
|
||||||
where
|
oauth2GoogleScopedWithCustomId toCreds scopes clientId clientSecret =
|
||||||
oauth = OAuth2
|
authOAuth2 "google" oauth $ fetchGoogleProfile toCreds
|
||||||
{ oauthClientId = encodeUtf8 clientId
|
|
||||||
, oauthClientSecret = encodeUtf8 clientSecret
|
|
||||||
, oauthOAuthorizeEndpoint = encodeUtf8 $
|
|
||||||
"https://accounts.google.com/o/oauth2/auth?scope=" <> T.intercalate "+" scopes
|
|
||||||
, oauthAccessTokenEndpoint = "https://www.googleapis.com/oauth2/v3/token"
|
|
||||||
, oauthCallback = Nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
where
|
||||||
|
oauth = OAuth2
|
||||||
|
{ oauthClientId = encodeUtf8 clientId
|
||||||
|
, oauthClientSecret = encodeUtf8 clientSecret
|
||||||
|
, oauthOAuthorizeEndpoint = encodeUtf8
|
||||||
|
$ "https://accounts.google.com/o/oauth2/auth?scope=" <> T.intercalate "+" scopes
|
||||||
|
, oauthAccessTokenEndpoint = "https://www.googleapis.com/oauth2/v3/token"
|
||||||
|
, oauthCallback = Nothing
|
||||||
|
}
|
||||||
|
|
||||||
fetchGoogleProfile :: (GoogleUser -> AccessToken -> Creds m) -> Manager -> AccessToken -> IO (Creds m)
|
fetchGoogleProfile :: (GoogleUser -> AccessToken -> Creds m) -> Manager -> AccessToken -> IO (Creds m)
|
||||||
fetchGoogleProfile toCreds manager token = do
|
fetchGoogleProfile toCreds manager token = do
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user