yesod-auth-oauth2-0.2.1: OAuth 2.0 authentication plugins

Safe HaskellNone
LanguageHaskell98

Yesod.Auth.OAuth2

Description

Generic OAuth2 plugin for Yesod

  • See Yesod.Auth.OAuth2.GitHub for example usage.

Synopsis

Documentation

authOAuth2 Source #

Arguments

:: YesodAuth m 
=> Text

Service name

-> OAuth2

Service details

-> (Manager -> AccessToken -> IO (Creds m))

This function defines how to take an AccessToken and retrieve additional information about the user, to be set in the session as Creds. Usually this means a second authorized request to api/me.json.

See fromProfileURL for an example.

-> AuthPlugin m 

Create an AuthPlugin for the given OAuth2 provider

Presents a generic "Login via name" link

authOAuth2Widget :: YesodAuth m => WidgetT m IO () -> Text -> OAuth2 -> (Manager -> AccessToken -> IO (Creds m)) -> AuthPlugin m Source #

Create an AuthPlugin for the given OAuth2 provider

Allows passing a custom widget for the login link. See oauth2Eve for an example.

fromProfileURL Source #

Arguments

:: FromJSON a 
=> Text

Plugin name

-> URI

Profile URI

-> (a -> Creds m)

Conversion to Creds

-> Manager 
-> AccessToken 
-> IO (Creds m) 

Handle the common case of fetching Profile information from a JSON endpoint

Throws InvalidProfileResponse if JSON parsing fails

maybeExtra :: Text -> Maybe Text -> [(Text, Text)] Source #

A helper for providing an optional value to credsExtra