Facebook Android SDK Session openForPublish not creating a new session

android, facebook, facebook-android-sdk, facebook-graph-api

Solution

The short answer is, don't call openForPublish. Call openForRead, and then requestNewPublishPermissions later if you need publish permissions.

The long answer is, you can't request publish permissions (on a user who's never connected with Facebook before via your app) unless you already have basic or default permissions already (what you would get if you call openForRead with an empty permission set). So openForPublish actually handles a very specific niche use case that most apps probably don't have.

Problem

In the Facebook Android SDK when I call ``` Session tempSession = new Builder(this).build(); Session.setActiveSession(tempSession); tempSession.openForRead(new OpenRequest(this).setPermissions(FB_PERMISSIONS)); ``` It gets a FB session and every thing runs as normal. But when I replace `Read` with `Publish`. i.e. follows ``` Session tempSession = new Builder(this).build(); Session.setActiveSession(tempSession); tempSession.openForPublish(new OpenRequest(this).setPermissions(FB_PERMISSIONS)); ``` It gives an error saying, that the session is empty, and cannot get publish permissions to empty session. Can you please tell why is it like this and what would be the best way to handle this?

Original source