I'm trying to use Facebook SDK in my Android app. Here's the snippet:
Facebook myFacebook = new Facebook("123456789012345");
myFacebook.authorize(LogInScreen.this,
new String[] {
"publish_stream",
"email",
"user_about_me",
"user_birthday",
"user_website",
"friends_photos",
"user_photos"},
Facebook.FORCE_DIALOG_AUTH,
new DialogListener(){
@Override
public void onCancel() {
Log.i("Facebook", "Facebook - cancel");
}
@Override
public void onComplete(Bundle arg0) {
Log.i("Facebook", "Facebook - complete, AccessToken: " + myFacebook.getAccessToken());
}
@Override
public void onError(DialogError arg0) {
Log.i("Facebook", "Facebook - error");
}
@Override
public void onFacebookError(FacebookError error) {
Log.i("Facebook", "Facebook - facebookError: " + error);
try {
myFacebook.logout(LogInScreen.this);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}}
);
}
});
When I run this code, I can log in with my main facebook account, but when I try to use any other fb account I got error "Failed to receive access token". Am I missing something?
The problem was that the facebook app was set to sandbox mode, so only developer accounts could get access token from app's ID.
I had the same problem, but sandbox wasn't solution. I had some restrictions about countries and my country wasn't there. I added it and it resolved my problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With