问题
I am using the Facebook SDK but I want to create the photo album but I am getting ACCESS_TOKEN_REMOVED in the session.
Getting this in session
{Session state:OPENED, token:{AccessToken token:ACCESS_TOKEN_REMOVED permissions:[read_stream, manage_friendlists, read_mailbox, status_update, photo_upload, video_upload, sms, create_event, rsvp_event, email, xmpp_login, create_note, share_item, publish_stream, ads_management, read_insights, read_requests, manage_notifications, read_friendlists, manage_pages, publish_actions, user_birthday, user_religion_politics, user_relationships, user_relationship_details, user_hometown, user_location, user_likes, user_activities, user_interests, user_education_history, user_work_history, user_online_presence, user_website, user_groups, user_events, user_photos, user_videos, user_photo_video_tags, user_notes, user_checkins, user_about_me, user_status, basic_info]}, appId:458921577539675}
Code.
/**
* Connect to facebook using Facebook SDK.
*/
public void connectToFacebook() {
Session session = Session.getActiveSession();
if(session == null || session.isClosed()) {
Session.openActiveSession((Activity)context, true, new StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
if(session.isOpened() && state == SessionState.CREATED_TOKEN_LOADED) {
Log.v(GlobalVars.TAG, "Token::" + session.getAccessToken());
Request.executeMeRequestAsync(session, new GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
if(response != null) {
Log.v(GlobalVars.TAG, "Response::" + response);
Log.v(GlobalVars.TAG, "Response::" + user.getFirstName() + ":::" + user.getLastName());
}
}
});
}
}
});
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
回答1:
If you are just seeing ACCESS_TOKEN_REMOVED
in your log, make sure you are printing session.getAccessToken().getToken()
. In the example above, replace
Log.v(GlobalVars.TAG, "Token::" + session.getAccessToken());
with
Log.v(GlobalVars.TAG, "Token::" + session.getAccessToken().getToken());
回答2:
Same problem that i was facing from last 2 days and finally i get to know this. Facebook SDK will not log access tokens to logcat (to avoid leaking user tokens via the log as said in decsription).
Just add these lines after FacebookSdk.sdkInitialize(), i would recomend you do this only in debug mode:
if (BuildConfig.DEBUG) {
FacebookSdk.setIsDebugEnabled(true);
FacebookSdk.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);
}
回答3:
You have to enable facebook sign in on Firebase Console and add the facebook app id and app secret key and it should work fine
回答4:
I took the same problem :/
You can check:
- Is appId correct?
- Was keyhash registered in facebook app center?
- Does app namespace / package name match with your manifest file? ( on facebook app center )
- Is application live?
If everything is right I really don't know how to help you...
回答5:
I checked all items that Fernando said and add it
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
I don't know if this last line was what solved the problem or if it's something random.
I'm using Facebook Android SDK 3.17 for Xamarin
Greetings from Argentina Hernan www.hernanzaldivar.com
来源:https://stackoverflow.com/questions/18307535/accesstoken-tokenaccess-token-removed-in-facebook-android-sdk