yesod-auth-oauth2-0.7.0.2: OAuth 2.0 authentication plugins
Safe HaskellNone
LanguageHaskell2010

Yesod.Auth.OAuth2.Google

Description

OAuth2 plugin for http://www.google.com

  • Authenticates against Google
  • Uses Google user id as credentials identifier

If you were previously relying on email as the creds identifier, you can still do that (and more) by overriding it in the creds returned by the plugin with any value read out of the new userResponse key in credsExtra.

For example:

data User = User { userEmail :: Text }

instance FromJSON User where -- you know...

authenticate creds = do
    -- 'getUserResponseJSON' provided by "Yesod.Auth.OAuth" module
    let Right email = userEmail <$> getUserResponseJSON creds
        updatedCreds = creds { credsIdent = email }

    -- continue normally with updatedCreds

Documentation