无法使用 SocialAuth 从 Facebook 获取用户详细信息

Not able to get userDetails from facebook using SocialAuth

我正在使用 SocialAuth 库来集成 fb/linkedin。我已成功登录,但我能够获取用户配置文件。我的代码如下:

public class MainActivity extends Activity  implements View.OnClickListener{

Button fb,linkedIn;
SocialAuthAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    fb=(Button)findViewById(R.id.button);
    linkedIn=(Button)findViewById(R.id.button2);
    fb.setOnClickListener(this);
    linkedIn.setOnClickListener(this);

    adapter = new SocialAuthAdapter(new ResponseListener());
    adapter.addProvider(SocialAuthAdapter.Provider.FACEBOOK,R.drawable.facebook);
    adapter.addProvider(SocialAuthAdapter.Provider.LINKEDIN,R.drawable.linkedin);

    try{
        adapter.addConfig(SocialAuthAdapter.Provider.FACEBOOK,"901453509923310","29940b7c91f8a9d4db7e72f7e3e72e1d","publish_actions");

    }
    catch(Exception ex)
    {
        Log.e("Adding config",ex.toString());
    }


}


@Override
public void onClick(View view) {
    switch (view.getId()) {

        case R.id.button:
            adapter.authorize(MainActivity.this, SocialAuthAdapter.Provider.FACEBOOK);

            break;

        case R.id.button2:

            break;
    }


}

private final class ResponseListener implements DialogListener{

    @Override
    public void onComplete(Bundle bundle) {
        String token=adapter.getCurrentProvider().getAccessGrant().getKey();
        Log.e("KEY ",token);
        adapter.getUserProfileAsync(new ProfileDataListener());

    }

    @Override
    public void onError(SocialAuthError socialAuthError) {

        Log.e("ERRROR ", socialAuthError.getMessage());

    }

    @Override
    public void onCancel() {

    }

    @Override
    public void onBack() {

    }
}


private final class ProfileDataListener implements SocialAuthListener<Profile> {
    @Override
    public void onExecute(String s, Profile profile) {
        Profile profileMap = profile;

       // Log.d("Custom-UI","Validate ID         = " + profileMap.getValidatedId());
        Log.d("Info","First Name          = " + profileMap.getFirstName());
        Log.d("Info","Last Name           = " + profileMap.getLastName());
        Log.d("Info","Email               = " + profileMap.getEmail());
        Log.d("Info","Gender                   = " + profileMap.getGender());
        Log.d("Info","Country                  = " + profileMap.getCountry());
        Log.d("Info","Language                 = " + profileMap.getLanguage());
        Log.d("Info","Location                 = " + profileMap.getLocation());
        Log.d("Info","Profile Image URL  = " + profileMap.getProfileImageURL());

    }

    @Override
    public void onError(SocialAuthError socialAuthError) {
        Log.e("GETTING PROFILE INFO ",socialAuthError.getMessage());

    }
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}


}

成功登录后,我得到以下 logcat :

请帮助我,我一直停留在这一点上。谢谢

您可以使用 facebook sdk 代替社交身份验证

您似乎没有要求用户个人资料权限。在 Facebook SDK 中它看起来像这样

mFacebookLoginManager.logInWithReadPermissions(this, Arrays.asList("public_profile", "email"));

所以我猜想在 SocialAuth 的某处有一行请求权限。此外,您必须使用应用程序 ID 对您的应用程序进行签名,该应用程序 ID 是在您注册为 Facebook 开发人员后由 Facebook 提供给您的。