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

Safe HaskellNone
LanguageHaskell2010

Yesod.Auth.OAuth2

Contents

Description

Generic OAuth2 plugin for Yesod

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

Synopsis

Documentation

data OAuth2 :: * #

Query Parameter Representation

Instances

Eq OAuth2 

Methods

(==) :: OAuth2 -> OAuth2 -> Bool #

(/=) :: OAuth2 -> OAuth2 -> Bool #

Show OAuth2 

type FetchCreds m = Manager -> OAuth2Token -> IO (Creds m) Source #

How to take an OAuth2Token and retrieve user credentials

data Manager :: * #

Keeps track of open connections for keep-alive.

If possible, you should share a single Manager between multiple threads and requests.

Since 0.1.0

data OAuth2Token :: * #

The gained Access Token. Use Data.Aeson.decode to decode string to AccessToken. The refreshToken is special in some cases, e.g. https://developers.google.com/accounts/docs/OAuth2

data Creds master :: * -> * #

User credentials

Constructors

Creds 

Fields

Instances

Show (Creds master) 

Methods

showsPrec :: Int -> Creds master -> ShowS #

show :: Creds master -> String #

showList :: [Creds master] -> ShowS #

authOAuth2 :: YesodAuth m => Text -> OAuth2 -> FetchCreds m -> AuthPlugin m Source #

Create an AuthPlugin for the given OAuth2 provider

Presents a generic "Login via #{name}" link

authOAuth2Widget :: YesodAuth m => WidgetT m IO () -> Text -> OAuth2 -> FetchCreds 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.

Reading our credsExtra keys

getAccessToken :: Creds m -> Maybe AccessToken Source #

Read from the values set via setExtra

getUserResponse :: Creds m -> Maybe ByteString Source #

Read from the values set via setExtra

getUserResponseJSON :: FromJSON a => Creds m -> Either String a Source #

Read from the values set via setExtra, decode as JSON

This is unsafe if the key is missing, but safe with respect to parsing errors.