public class FacebookClient extends BaseOAuth20Client<FacebookProfile>
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, username, third_party_id, timezone, updated_time, verified, bio, 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 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/
FacebookProfile| Modifier and Type | Field and Description |
|---|---|
protected StateApi20 |
api20 |
protected static String |
BASE_URL |
static String |
DEFAULT_FIELDS |
static int |
DEFAULT_LIMIT |
static String |
DEFAULT_SCOPE |
protected String |
fields |
protected int |
limit |
protected boolean |
requiresExtendedToken |
protected String |
scope |
logger, OAUTH_CODEconnectTimeout, key, proxyHost, proxyPort, readTimeout, secret, service, tokenAsHeaderATTEMPTED_AUTHENTICATION_SUFFIX, callbackUrl, NEEDS_CLIENT_REDIRECTION_PARAMETER| Constructor and Description |
|---|
FacebookClient() |
FacebookClient(String key,
String secret) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
extractData(FacebookProfile profile,
com.fasterxml.jackson.databind.JsonNode json,
String name) |
protected FacebookProfile |
extractUserProfile(String body)
Extract the user profile from the response (JSON, XML...) of the profile url.
|
String |
getFields() |
int |
getLimit() |
protected String |
getProfileUrl(org.scribe.model.Token accessToken)
Retrieve the url of the profile of the authenticated user for the provider.
|
String |
getScope() |
protected boolean |
hasBeenCancelled(WebContext context)
Return if the authentication has been cancelled.
|
protected void |
internalInit() |
boolean |
isRequiresExtendedToken() |
protected FacebookClient |
newClient() |
protected boolean |
requiresStateParameter()
Return if this client requires a state parameter.
|
protected FacebookProfile |
retrieveUserProfileFromToken(org.scribe.model.Token accessToken)
Retrieve the user profile from the access token.
|
void |
setFields(String fields) |
void |
setLimit(int limit) |
void |
setRequiresExtendedToken(boolean requiresExtendedToken) |
void |
setScope(String scope) |
getAccessToken, getOAuthCredentials, getStateParameter, isDirectRedirection, retrieveAuthorizationUrladdAccessTokenToProfile, clone, createProxyRequest, getConnectTimeout, getKey, getMechanism, getProxyHost, getProxyPort, getReadTimeout, getSecret, getUserProfile, isTokenAsHeader, retrieveCredentials, retrieveRedirectAction, retrieveUserProfile, sendRequestForData, sendRequestForData, setConnectTimeout, setKey, setProxyHost, setProxyPort, setReadTimeout, setSecret, setTokenAsHeaderaddAuthorizationGenerator, getAuthenticator, getAuthorizationGenerators, getCallbackUrl, getContextualCallbackUrl, getCredentials, getName, getProfileCreator, getRedirectAction, getRedirectionUrl, getUserProfile, isEnableContextualRedirects, isIncludeClientNameInCallbackUrl, prependHostToUrlIfNotPresent, redirect, setAuthenticator, setAuthorizationGenerator, setAuthorizationGenerators, setCallbackUrl, setEnableContextualRedirects, setIncludeClientNameInCallbackUrl, setName, setProfileCreator, toStringinit, reinitpublic static final String DEFAULT_FIELDS
protected String fields
protected static final String BASE_URL
public static final String DEFAULT_SCOPE
protected String scope
public static final int DEFAULT_LIMIT
protected int limit
protected boolean requiresExtendedToken
protected StateApi20 api20
protected FacebookClient newClient()
newClient in class BaseClient<OAuthCredentials,FacebookProfile>protected void internalInit()
internalInit in class BaseOAuthClient<FacebookProfile>protected String getProfileUrl(org.scribe.model.Token accessToken)
BaseOAuthClientgetProfileUrl in class BaseOAuthClient<FacebookProfile>accessToken - only used when constructing dynamic urls from data in the tokenprotected FacebookProfile retrieveUserProfileFromToken(org.scribe.model.Token accessToken)
BaseOAuthClientretrieveUserProfileFromToken in class BaseOAuthClient<FacebookProfile>accessToken - the access tokenprotected FacebookProfile extractUserProfile(String body)
BaseOAuthClientextractUserProfile in class BaseOAuthClient<FacebookProfile>body - the response bodyprotected void extractData(FacebookProfile profile, com.fasterxml.jackson.databind.JsonNode json, String name)
protected boolean hasBeenCancelled(WebContext context)
BaseOAuthClienthasBeenCancelled in class BaseOAuthClient<FacebookProfile>context - the web context.public String getScope()
public void setScope(String scope)
public String getFields()
public void setFields(String fields)
public int getLimit()
public void setLimit(int limit)
public boolean isRequiresExtendedToken()
public void setRequiresExtendedToken(boolean requiresExtendedToken)
protected boolean requiresStateParameter()
BaseOAuth20ClientrequiresStateParameter in class BaseOAuth20Client<FacebookProfile>Copyright © 2015. All Rights Reserved.