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

Safe HaskellNone
LanguageHaskell2010

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 -> OAuth2Token -> IO (Creds m))

This function defines how to take an OAuth2Token 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 -> OAuth2Token -> 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 
-> OAuth2Token 
-> IO (Creds m) 

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

Throws InvalidProfileResponse if JSON parsing fails

invalidProfileResponse :: Text -> OAuth2Error Value -> YesodOAuth2Exception Source #

Construct an InvalidProfileResponse exception from an OAuth2Error

This forces the e in OAuth2Error e to parse as a JSON Value which is then re-encoded for the exception message.

scopeParam :: Text -> [Text] -> (ByteString, ByteString) Source #

A tuple of scope and the given scopes separated by a delimiter

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

A helper for providing an optional value to credsExtra