Class FacebookClient

java.lang.Object
org.pac4j.core.util.InitializableObject
org.pac4j.core.client.BaseClient
org.pac4j.core.client.IndirectClient
org.pac4j.oauth.client.OAuth20Client
org.pac4j.oauth.client.FacebookClient
All Implemented Interfaces:
org.pac4j.core.client.Client

public class FacebookClient extends OAuth20Client

This class is the OAuth client to authenticate users in Facebook.

By default, the following scope is requested to Facebook: user_likes, user_about_me, user_birthday, user_education_history, email, user_hometown, user_relationship_details, user_location, user_religion_politics, user_relationships, user_website and user_work_history.

The scope can be defined to require permissions from the user and retrieve fields from Facebook, by using the setScope(String) method.

By default, the following fields are requested to Facebook: id, name, first_name, middle_name, last_name, gender, locale, languages, link, third_party_id, timezone, updated_time, verified, about, birthday, education, email, hometown, interested_in, location, political, favorite_athletes, favorite_teams, quotes, relationship_status, religion, significant_other, website and work.

The fields can be defined and requested to Facebook, by using the setFields(String) method.

The number of results can be limited by using the setLimit(int) method.

An extended access token can be requested by setting true on the FacebookConfiguration#setRequiresExtendedToken(boolean) method.

It returns a FacebookProfile.

More information at http://developers.facebook.com/docs/reference/api/user/

More information at https://developers.facebook.com/docs/howtos/login/extending-tokens/

Since:
1.0.0
Author:
Jerome Leleu, Mehdi BEN HAJ ABBES
  • Field Summary

    Fields inherited from class org.pac4j.oauth.client.OAuth20Client

    configuration

    Fields inherited from class org.pac4j.core.client.IndirectClient

    ATTEMPTED_AUTHENTICATION_SUFFIX, callbackUrl, callbackUrlResolver, urlResolver

    Fields inherited from class org.pac4j.core.client.BaseClient

    logger, saveProfileInSession
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for FacebookClient.
    Constructor for FacebookClient.
  • Method Summary

    Modifier and Type
    Method
    Description
    getFields.
    int
    getLimit.
    getScope.
    protected void
    internalInit(boolean forceReinit)
    void
    setFields(String fields)
    setFields.
    void
    setLimit(int limit)
    setLimit.
    void
    setScope.

    Methods inherited from class org.pac4j.oauth.client.OAuth20Client

    beforeInternalInit, getKey, getSecret, setKey, setSecret

    Methods inherited from class org.pac4j.core.client.IndirectClient

    afterInternalInit, checkCredentials, computeFinalCallbackUrl, getAjaxRequestResolver, getCallbackUrl, getCallbackUrlResolver, getCodeVerifierSessionAttributeName, getLogoutAction, getLogoutActionBuilder, getLogoutProcessor, getNonceSessionAttributeName, getRedirectionAction, getRedirectionActionBuilder, getStateSessionAttributeName, getUrlResolver, isCheckAuthenticationAttempt, newDefaultCallbackUrlResolver, processLogout, setAjaxRequestResolver, setCallbackUrl, setCallbackUrlResolver, setCheckAuthenticationAttempt, setLogoutActionBuilder, setLogoutActionBuilderIfUndefined, setLogoutProcessor, setLogoutProcessorIfUndefined, setRedirectionActionBuilder, setRedirectionActionBuilderIfUndefined, setUrlResolver, toString

    Methods inherited from class org.pac4j.core.client.BaseClient

    addAuthorizationGenerator, addAuthorizationGenerators, getAuthenticator, getAuthorizationGenerators, getCredentials, getCredentialsExtractor, getCustomProperties, getLogger, getName, getProfileCreator, getProfileFactoryWhenNotAuthenticated, getSaveProfileInSession, getSaveProfileInSession, getUserProfile, internalValidateCredentials, isMultiProfile, isMultiProfile, notifySessionRenewal, renewUserProfile, setAuthenticator, setAuthenticatorIfUndefined, setAuthorizationGenerator, setAuthorizationGenerators, setAuthorizationGenerators, setCredentialsExtractor, setCredentialsExtractorIfUndefined, setCustomProperties, setMultiProfile, setName, setProfileCreator, setProfileCreatorIfUndefined, setProfileFactoryWhenNotAuthenticated, setSaveProfileInSession, validateCredentials

    Methods inherited from class org.pac4j.core.util.InitializableObject

    getInitialized, getLastAttempt, getMaxAttempts, getMinTimeIntervalBetweenAttemptsInMilliseconds, getNbAttempts, init, init, isInitialized, reinit, setMaxAttempts, setMinTimeIntervalBetweenAttemptsInMilliseconds, shouldInitialize

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • FacebookClient

      public FacebookClient()

      Constructor for FacebookClient.

    • FacebookClient

      public FacebookClient(String key, String secret)

      Constructor for FacebookClient.

      Parameters:
      key - a String object
      secret - a String object
  • Method Details

    • internalInit

      protected void internalInit(boolean forceReinit)
      Overrides:
      internalInit in class OAuth20Client
    • getConfiguration

      public FacebookConfiguration getConfiguration()
    • getScope

      public String getScope()

      getScope.

      Returns:
      a String object
    • setScope

      public void setScope(String scope)

      setScope.

      Parameters:
      scope - a String object
    • getFields

      public String getFields()

      getFields.

      Returns:
      a String object
    • setFields

      public void setFields(String fields)

      setFields.

      Parameters:
      fields - a String object
    • getLimit

      public int getLimit()

      getLimit.

      Returns:
      a int
    • setLimit

      public void setLimit(int limit)

      setLimit.

      Parameters:
      limit - a int