Preethi Rao
Preethi Rao

Reputation: 5175

Facebook session with extended permission validity of the accesstoken

I need to send the message to the facebook friends of current user through my android app

I could get the extended permission "xmpp login" for the session from the facebook. Problem: Every time when i have to send the message i have ask for the "xmpp_login" permission. Only one message i can send with that access token.

The block of code i wrote for asking for the new permission

private static final List<String> INIVITE_PERMISSION = Arrays.asList(
        "publish_stream, publish_actions", "xmpp_login");




Session session = Session.getActiveSession();
                    List<String> permissions    =session.getPermissions();
                    for(int i=0;i<permissions.size();i++)
                        Log.e("permissions",""+permissions.get(i));
                    if(!permissions.contains("xmpp_login"))
                    {
                    Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(
                            (Activity)mCtx, INIVITE_PERMISSION)
                            // demonstrate how to set an audience for the publish
                            // permissions,
                            // if none are set, this defaults to FRIENDS
                            .setDefaultAudience(SessionDefaultAudience.FRIENDS)
                            .setRequestCode(100);
                    session.requestNewPublishPermissions(newPermissionsRequest);

                    session.requestNewPublishPermissions(new NewPermissionsRequest((Activity)mCtx, INIVITE_PERMISSION));




                    }

Upvotes: 1

Views: 494

Answers (1)

Preethi Rao
Preethi Rao

Reputation: 5175

I found the answer for this question.

I was getting this permission all the time just because xmpp_login comes under read permission. I was asking permission for publish request. So it used ask the permission all the time.

`private static final List<String> INIVITE_PERMISSION = Arrays.asList(
        "publish_stream, publish_actions", "xmpp_login");`

should be private static final List<String> INIVITE_PERMISSION = Arrays.asList("xmpp_login"); and i had to change session.requestNewPublishPermissions(newPermissionsRequest); to session.requestNewRead Permissions(newPermissionsRequest);

Upvotes: 2

Related Questions