本文介绍了Android的SDK Facebook的 - 无法获得访问令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使用Facebook SDK在我的Android应用程序。这里的片段:
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();
}
}}
);
}
});
当我运行这个code,我可以用我的主要的Facebook帐户登录,但是当我尝试使用任何其他的FB账号我得到错误无法获得访问令牌。我缺少的东西吗?
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?
推荐答案
的问题是,Facebook应用程序设置为沙盒模式,因此,只有开发者帐户可以从应用程序的ID获得访问令牌。
The problem was that the facebook app was set to sandbox mode, so only developer accounts could get access token from app's ID.
这篇关于Android的SDK Facebook的 - 无法获得访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!