use of com.facebook.FacebookAuthorizationException in project phonegap-facebook-plugin by Wizcorp.
the class ConnectPlugin method onSessionStateChange.
/*
* Handles session state changes
*/
private void onSessionStateChange(SessionState state, Exception exception) {
Log.d(TAG, "onSessionStateChange:" + state.toString());
if (exception != null && exception instanceof FacebookOperationCanceledException) {
// only handle FacebookOperationCanceledException to support
// SDK recovery behavior triggered by getUserInfo
Log.e(TAG, "exception:" + exception.toString());
handleError(exception, loginContext);
} else {
final Session session = Session.getActiveSession();
// Check if the session is open
if (state.isOpened()) {
if (loginContext != null) {
// Get user info
getUserInfo(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
// Create a new result with response data
if (loginContext != null) {
if (response.getError() != null) {
loginContext.error(getFacebookRequestErrorResponse(response.getError()));
} else {
GraphObject graphObject = response.getGraphObject();
Log.d(TAG, "returning login object " + graphObject.getInnerJSONObject().toString());
userID = user.getId();
loginContext.success(getResponse());
loginContext = null;
}
} else {
// Just update the userID in case we force quit the application before
userID = user.getId();
}
}
});
} else if (graphContext != null) {
// Make the graph call
makeGraphCall();
}
} else if (state == SessionState.CLOSED_LOGIN_FAILED && loginContext != null) {
handleError(new FacebookAuthorizationException("Session was closed and was not closed normally"), loginContext);
}
}
}
use of com.facebook.FacebookAuthorizationException in project facebook-android-sdk by facebook.
the class LoginManager method onActivityResult.
boolean onActivityResult(int resultCode, Intent data, FacebookCallback<LoginResult> callback) {
FacebookException exception = null;
AccessToken newToken = null;
LoginClient.Result.Code code = LoginClient.Result.Code.ERROR;
Map<String, String> loggingExtras = null;
LoginClient.Request originalRequest = null;
boolean isCanceled = false;
if (data != null) {
LoginClient.Result result = data.getParcelableExtra(LoginFragment.RESULT_KEY);
if (result != null) {
originalRequest = result.request;
code = result.code;
if (resultCode == Activity.RESULT_OK) {
if (result.code == LoginClient.Result.Code.SUCCESS) {
newToken = result.token;
} else {
exception = new FacebookAuthorizationException(result.errorMessage);
}
} else if (resultCode == Activity.RESULT_CANCELED) {
isCanceled = true;
}
loggingExtras = result.loggingExtras;
}
} else if (resultCode == Activity.RESULT_CANCELED) {
isCanceled = true;
code = LoginClient.Result.Code.CANCEL;
}
if (exception == null && newToken == null && !isCanceled) {
exception = new FacebookException("Unexpected call to LoginManager.onActivityResult");
}
boolean wasLoginActivityTried = true;
//Sadly, there is no way to get activity context at this point.S
Context context = null;
logCompleteLogin(context, code, loggingExtras, exception, wasLoginActivityTried, originalRequest);
finishLogin(newToken, originalRequest, exception, isCanceled, callback);
return true;
}
Aggregations