yesod-auth-oauth2- OAuth 2.0 authentication plugins

Safe HaskellNone



OAuth2 plugin for

  • 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