yesod-auth-1.6.11.3: Authentication for Yesod.

Safe Haskell | None
Language | Haskell2010

Yesod.Auth.GoogleEmail2

Contents

- Authentication handlers
- User authentication token
- Person
- Other functions

Description

Deprecated: Google+ is being shut down, please migrate to Google Sign-in https://pbrisbin.com/posts/googleemail2_deprecation/

Use an email address as an identifier via Google's login system.

Note that this is a replacement for Yesod.Auth.GoogleEmail, which depends on Google's now deprecated OpenID system. For more information, see https://developers.google.com/+/api/auth-migration.

By using this plugin, you are trusting Google to validate an email address, and requiring users to have a Google account. On the plus side, you get to use email addresses as the identifier, many users have existing Google accounts, the login system has been long tested (as opposed to BrowserID), and it requires no credential managing or setup (as opposed to Email).

In order to use this plugin:

- Create an application on the Google Developer Console https://console.developers.google.com/
- Create OAuth credentials. The redirect URI will be http://yourdomain/auth/page/googleemail2/complete. (If you have your authentication subsite at a different root than /auth/, please adjust accordingly.)
- Enable the Google+ API.

Since: 1.3.1

Synopsis

- authGoogleEmail :: YesodAuth m => Text -> Text -> AuthPlugin m
- authGoogleEmailSaveToken :: YesodAuth m => Text -> Text -> AuthPlugin m
- forwardUrl :: AuthRoute
- data Token = Token {
  - accessToken :: Text
  - tokenType :: Text
  }
- getUserAccessToken :: MonadHandler m => m (Maybe Token)
- getPerson :: MonadHandler m => Manager -> Token -> m (Maybe Person)
- data Person = Person {
  - personId :: Text
  - personDisplayName :: Maybe Text
  - personName :: Maybe Name
  - personNickname :: Maybe Text
  - personBirthday :: Maybe Text
  - personGender :: Maybe Gender
  - personProfileUri :: Maybe Text
  - personImage :: Maybe PersonImage
  - personAboutMe :: Maybe Text
  - personRelationshipStatus :: Maybe RelationshipStatus
  - personUris :: [PersonURI]
  - personOrganizations :: [Organization]
  - personPlacesLived :: [Place]
  - personTagline :: Maybe Text
  - personIsPlusUser :: Maybe Bool
  - personBraggingRights :: Maybe Text
  - personPlusOneCount :: Maybe Int
  - personCircledByCount :: Maybe Int
  - personVerified :: Maybe Bool
  - personLanguage :: Maybe Text
  - personEmails :: [Email]
  - personDomain :: Maybe Text
  - personOccupation :: Maybe Text
  - personSkills :: Maybe Text
  }
- data Name = Name {
  - nameFormatted :: Maybe Text
  - nameFamily :: Maybe Text
  - nameGiven :: Maybe Text
  - nameMiddle :: Maybe Text
  - nameHonorificPrefix :: Maybe Text
  - nameHonorificSuffix :: Maybe Text
  }
- data Gender
  - = Male
  - | Female
  - | OtherGender
- newtype PersonImage = PersonImage {
  - imageUri :: Text
  }
- resizePersonImage :: PersonImage -> Int -> PersonImage
- data RelationshipStatus
  - = Single
  - | InRelationship
  - | Engaged
  - | Married
  - | Complicated
  - | OpenRelationship
  - | Widowed
  - | DomesticPartnership
  - | CivilUnion
  - | RelationshipStatus Text
- data PersonURI = PersonURI {
  - uriLabel :: Maybe Text
  - uriValue :: Maybe Text
  - uriType :: Maybe PersonURIType
  }
- data PersonURIType
  - = OtherProfile
  - | Contributor
  - | Website
  - | OtherURI
  - | PersonURIType Text
- data Organization = Organization {
  - orgName :: Maybe Text
  - orgTitle :: Maybe Text
  - orgType :: Maybe OrganizationType
  - orgStartDate :: Maybe Text
  - orgEndDate :: Maybe Text
  - orgPrimary :: Maybe Bool
  }
- data OrganizationType
  - = Work
  - | School
  - | OrganizationType Text
- data Place = Place {
  - placeValue :: Maybe Text
  - placePrimary :: Maybe Bool
  }
- data Email = Email {
  - emailValue :: Text
  - emailType :: EmailType
  }
- data EmailType
  - = EmailAccount
  - | EmailHome
  - | EmailWork
  - | EmailOther
  - | EmailType Text
- pid :: Text

# Authentication handlers

authGoogleEmail Source #

Arguments

:: YesodAuth m |
=> Text | client ID
-> Text | client secret
-> AuthPlugin m |

authGoogleEmailSaveToken Source #

Arguments

:: YesodAuth m |
=> Text | client ID
-> Text | client secret
-> AuthPlugin m |

An alternative version which stores user access token in the session variable. Use it if you want to request user's profile from your app.

Since: 1.4.3

forwardUrl :: AuthRoute Source #

# User authentication token

data Token Source #

An authentication token which was acquired from OAuth callback. The token gets saved into the session storage only if you use `authGoogleEmailSaveToken`. You can acquire saved token with `getUserAccessToken`.

Since: 1.4.3

Constructors

Token |

Fields

- accessToken :: Text
- tokenType :: Text

#### Instances

Instances details

FromJSON Token Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods parseJSON :: Value -> Parser Token Source # parseJSONList :: Value -> Parser [Token] Source # omittedField :: Maybe Token Source #
Show Token Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods showsPrec :: Int -> Token -> ShowS Source # show :: Token -> String Source # showList :: [Token] -> ShowS Source #
Eq Token Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods (==) :: Token -> Token -> Bool Source # (/=) :: Token -> Token -> Bool Source #

getUserAccessToken :: MonadHandler m => m (Maybe Token) Source #

Get user's access token from the session. Returns Nothing if it's not found (probably because the user is not logged in via `GoogleEmail2` or you are not using `authGoogleEmailSaveToken`)

# Person

getPerson :: MonadHandler m => Manager -> Token -> m (Maybe Person) Source #

Allows to fetch information about a user from Google's API. In case of parsing error returns `Nothing`. Will throw `HttpException` in case of network problems or error response code.

Since: 1.4.3

data Person Source #

Information about the user Full description of the resource https://developers.google.com/+/api/latest/people

Since: 1.4.3

Constructors

Person |

Fields

- personId :: Text
- personDisplayName :: Maybe Text

  The name of this person, which is suitable for display

- personName :: Maybe Name
- personNickname :: Maybe Text
- personBirthday :: Maybe Text

  Birthday formatted as YYYY-MM-DD

- personGender :: Maybe Gender
- personProfileUri :: Maybe Text

  The URI of this person's profile

- personImage :: Maybe PersonImage
- personAboutMe :: Maybe Text

  A short biography for this person

- personRelationshipStatus :: Maybe RelationshipStatus
- personUris :: [PersonURI]
- personOrganizations :: [Organization]
- personPlacesLived :: [Place]
- personTagline :: Maybe Text

  The brief description of this person

- personIsPlusUser :: Maybe Bool

  Whether this user has signed up for Google+

- personBraggingRights :: Maybe Text

  The "bragging rights" line of this person

- personPlusOneCount :: Maybe Int

  if a Google+ page, the number of people who have +1'd this page

- personCircledByCount :: Maybe Int

  For followers who are visible, the number of people who have added this person or page to a circle.

- personVerified :: Maybe Bool

  Whether the person or Google+ Page has been verified. This is used only for pages with a higher risk of being impersonated or similar. This flag will not be present on most profiles.

- personLanguage :: Maybe Text

  The user's preferred language for rendering.

- personEmails :: [Email]
- personDomain :: Maybe Text
- personOccupation :: Maybe Text

  The occupation of this person

- personSkills :: Maybe Text

  The person's skills

#### Instances

Instances details

FromJSON Person Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods parseJSON :: Value -> Parser Person Source # parseJSONList :: Value -> Parser [Person] Source # omittedField :: Maybe Person Source #
Show Person Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods showsPrec :: Int -> Person -> ShowS Source # show :: Person -> String Source # showList :: [Person] -> ShowS Source #
Eq Person Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods (==) :: Person -> Person -> Bool Source # (/=) :: Person -> Person -> Bool Source #

data Name Source #

Individual components of a name

Since: 1.4.3

Constructors

Name |

Fields

- nameFormatted :: Maybe Text

  The full name of this person, including middle names, suffixes, etc

- nameFamily :: Maybe Text

  The family name (last name) of this person

- nameGiven :: Maybe Text

  The given name (first name) of this person

- nameMiddle :: Maybe Text

  The middle name of this person.

- nameHonorificPrefix :: Maybe Text

  The honorific prefixes (such as "Dr." or "Mrs.") for this person

- nameHonorificSuffix :: Maybe Text

  The honorific suffixes (such as "Jr.") for this person

#### Instances

Instances details

FromJSON Name Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods parseJSON :: Value -> Parser Name Source # parseJSONList :: Value -> Parser [Name] Source # omittedField :: Maybe Name Source #
Show Name Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods showsPrec :: Int -> Name -> ShowS Source # show :: Name -> String Source # showList :: [Name] -> ShowS Source #
Eq Name Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods (==) :: Name -> Name -> Bool Source # (/=) :: Name -> Name -> Bool Source #

data Gender Source #

Gender of the person

Since: 1.4.3

Constructors

Male |
Female |
OtherGender |

#### Instances

Instances details

FromJSON Gender Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods parseJSON :: Value -> Parser Gender Source # parseJSONList :: Value -> Parser [Gender] Source # omittedField :: Maybe Gender Source #
Show Gender Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods showsPrec :: Int -> Gender -> ShowS Source # show :: Gender -> String Source # showList :: [Gender] -> ShowS Source #
Eq Gender Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods (==) :: Gender -> Gender -> Bool Source # (/=) :: Gender -> Gender -> Bool Source #

newtype PersonImage Source #

The URI of the person's profile photo.

Since: 1.4.3

Constructors

PersonImage |

Fields

- imageUri :: Text

#### Instances

Instances details

FromJSON PersonImage Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods parseJSON :: Value -> Parser PersonImage Source # parseJSONList :: Value -> Parser [PersonImage] Source # omittedField :: Maybe PersonImage Source #
Show PersonImage Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods showsPrec :: Int -> PersonImage -> ShowS Source # show :: PersonImage -> String Source # showList :: [PersonImage] -> ShowS Source #
Eq PersonImage Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods (==) :: PersonImage -> PersonImage -> Bool Source # (/=) :: PersonImage -> PersonImage -> Bool Source #

resizePersonImage :: PersonImage -> Int -> PersonImage Source #

`resizePersonImage img 30` would set query part to `?sz=30` which would resize the image under the URI. If for some reason you need to modify the query part, you should do it after resizing.

Since: 1.4.3

data RelationshipStatus Source #

The person's relationship status.

Since: 1.4.3

Constructors

Single | Person is single
InRelationship | Person is in a relationship
Engaged | Person is engaged
Married | Person is married
Complicated | The relationship is complicated
OpenRelationship | Person is in an open relationship
Widowed | Person is widowed
DomesticPartnership | Person is in a domestic partnership
CivilUnion | Person is in a civil union
RelationshipStatus Text | Something else

#### Instances

Instances details

FromJSON RelationshipStatus Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods parseJSON :: Value -> Parser RelationshipStatus Source # parseJSONList :: Value -> Parser [RelationshipStatus] Source # omittedField :: Maybe RelationshipStatus Source #
Show RelationshipStatus Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods showsPrec :: Int -> RelationshipStatus -> ShowS Source # show :: RelationshipStatus -> String Source # showList :: [RelationshipStatus] -> ShowS Source #
Eq RelationshipStatus Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods (==) :: RelationshipStatus -> RelationshipStatus -> Bool Source # (/=) :: RelationshipStatus -> RelationshipStatus -> Bool Source #

data PersonURI Source #

URIs specified in the person's profile

Since: 1.4.3

Constructors

PersonURI |

Fields

- uriLabel :: Maybe Text
- uriValue :: Maybe Text
- uriType :: Maybe PersonURIType

#### Instances

Instances details

FromJSON PersonURI Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods parseJSON :: Value -> Parser PersonURI Source # parseJSONList :: Value -> Parser [PersonURI] Source # omittedField :: Maybe PersonURI Source #
Show PersonURI Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods showsPrec :: Int -> PersonURI -> ShowS Source # show :: PersonURI -> String Source # showList :: [PersonURI] -> ShowS Source #
Eq PersonURI Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods (==) :: PersonURI -> PersonURI -> Bool Source # (/=) :: PersonURI -> PersonURI -> Bool Source #

data PersonURIType Source #

The type of URI

Since: 1.4.3

Constructors

OtherProfile | URI for another profile
Contributor | URI to a site for which this person is a contributor
Website | URI for this Google+ Page's primary website
OtherURI | Other URL
PersonURIType Text | Something else

#### Instances

Instances details

FromJSON PersonURIType Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods parseJSON :: Value -> Parser PersonURIType Source # parseJSONList :: Value -> Parser [PersonURIType] Source # omittedField :: Maybe PersonURIType Source #
Show PersonURIType Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods showsPrec :: Int -> PersonURIType -> ShowS Source # show :: PersonURIType -> String Source # showList :: [PersonURIType] -> ShowS Source #
Eq PersonURIType Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods (==) :: PersonURIType -> PersonURIType -> Bool Source # (/=) :: PersonURIType -> PersonURIType -> Bool Source #

data Organization Source #

Current or past organizations with which this person is associated

Since: 1.4.3

Constructors

Organization |

Fields

- orgName :: Maybe Text

  The person's job title or role within the organization

- orgTitle :: Maybe Text
- orgType :: Maybe OrganizationType

  The date that the person joined this organization.

- orgStartDate :: Maybe Text

  The date that the person left this organization.

- orgEndDate :: Maybe Text

  If `True`, indicates this organization is the person's ^ primary one, which is typically interpreted as the current one.

- orgPrimary :: Maybe Bool

#### Instances

Instances details

FromJSON Organization Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods parseJSON :: Value -> Parser Organization Source # parseJSONList :: Value -> Parser [Organization] Source # omittedField :: Maybe Organization Source #
Show Organization Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods showsPrec :: Int -> Organization -> ShowS Source # show :: Organization -> String Source # showList :: [Organization] -> ShowS Source #
Eq Organization Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods (==) :: Organization -> Organization -> Bool Source # (/=) :: Organization -> Organization -> Bool Source #

data OrganizationType Source #

The type of an organization

Since: 1.4.3

Constructors

Work |
School |
OrganizationType Text | Something else

#### Instances

Instances details

FromJSON OrganizationType Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods parseJSON :: Value -> Parser OrganizationType Source # parseJSONList :: Value -> Parser [OrganizationType] Source # omittedField :: Maybe OrganizationType Source #
Show OrganizationType Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods showsPrec :: Int -> OrganizationType -> ShowS Source # show :: OrganizationType -> String Source # showList :: [OrganizationType] -> ShowS Source #
Eq OrganizationType Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods (==) :: OrganizationType -> OrganizationType -> Bool Source # (/=) :: OrganizationType -> OrganizationType -> Bool Source #

data Place Source #

A place where the person has lived or is living at the moment.

Since: 1.4.3

Constructors

Place |

Fields

- placeValue :: Maybe Text

  A place where this person has lived. For example: "Seattle, WA", "Near Toronto".

- placePrimary :: Maybe Bool

  If `True`, this place of residence is this person's primary residence.

#### Instances

Instances details

FromJSON Place Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods parseJSON :: Value -> Parser Place Source # parseJSONList :: Value -> Parser [Place] Source # omittedField :: Maybe Place Source #
Show Place Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods showsPrec :: Int -> Place -> ShowS Source # show :: Place -> String Source # showList :: [Place] -> ShowS Source #
Eq Place Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods (==) :: Place -> Place -> Bool Source # (/=) :: Place -> Place -> Bool Source #

data Email Source #

Person's email

Since: 1.4.3

Constructors

Email |

Fields

- emailValue :: Text
- emailType :: EmailType

#### Instances

Instances details

FromJSON Email Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods parseJSON :: Value -> Parser Email Source # parseJSONList :: Value -> Parser [Email] Source # omittedField :: Maybe Email Source #
Show Email Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods showsPrec :: Int -> Email -> ShowS Source # show :: Email -> String Source # showList :: [Email] -> ShowS Source #
Eq Email Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods (==) :: Email -> Email -> Bool Source # (/=) :: Email -> Email -> Bool Source #

data EmailType Source #

Type of email

Since: 1.4.3

Constructors

EmailAccount | Google account email address
EmailHome | Home email address
EmailWork | Work email adress
EmailOther | Other email address
EmailType Text | Something else

#### Instances

Instances details

FromJSON EmailType Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods parseJSON :: Value -> Parser EmailType Source # parseJSONList :: Value -> Parser [EmailType] Source # omittedField :: Maybe EmailType Source #
Show EmailType Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods showsPrec :: Int -> EmailType -> ShowS Source # show :: EmailType -> String Source # showList :: [EmailType] -> ShowS Source #
Eq EmailType Source # |
Instance details Defined in Yesod.Auth.GoogleEmail2 Methods (==) :: EmailType -> EmailType -> Bool Source # (/=) :: EmailType -> EmailType -> Bool Source #

# Other functions

pid :: Text Source #

Plugin identifier. This is used to identify the plugin used for authentication. The `credsPlugin` will contain this value when this plugin is used for authentication. @since 1.4.17