* @return {@link Facebook} instance
*/
public Facebook getFacebook() throws FacebookException {
if (facebook == null) {
final Configuration configuration = getConfiguration();
FacebookFactory factory = new FacebookFactory(configuration);
if (this.oAuthAccessToken == null) {
// app login
facebook = factory.getInstance(new OAuthAuthorization(configuration));
// also get the App access token
facebook.getOAuthAppAccessToken();
LOG.warn("Login with app id and secret, access to some APIs is restricted!");
} else {
// user login with token
facebook = factory.getInstance();
// verify the access token
facebook.getOAuthAccessToken();
LOG.debug("Login with app id, secret and token, all APIs accessible");
}
}