开发者

Ask for extended permissions with a valid user session in iphone sdk

My iphone app is implementing the standard facebook connect feature using the facebook sdk. in the first step only the offline_access permission is asked to the user.

Now I need to ask for the publish_stream permission to the user already authenticated.

What I'm doing here is using the same "authorize:delegate:" method of the Facebook class to ask for extended permissions with the only difference I'm setting the accessToken and expirationDate property of the facebook manager with the values acquired from the first authentication:

Facebook *facebook = [[Facebook alloc] initWithAppId:@"YOUR_APP_ID"];
facebook.accessToken = /* read access token from user defaults */;
facebook.expirationDate = /* read expiration date from user defaults */;

NSArray *permissions =  [NSArray arrayWithObject:@"publish_stream"];
[facebook authorize:permissions delegate:self];

This works fine, except for some cases: it might happen that a new login dialog is displayed to user before asking for th开发者_开发技巧e new permissions.

This is a problem for my implementation because the user may potentially login with different credentials and broke my session.

I can't figure out why this is happening having asked the user for the offline access too. I'm still wondering whether setting access token and expiration date is actually required or not.


Facebook *facebook = [[Facebook alloc] initWithAppId:@"YOUR_APP_ID"];
//facebook.accessToken = /* read access token from user defaults */;
//facebook.expirationDate = /* read expiration date from user defaults */;

[facebook setAccessToken:urtoken];

[facebook setExpirationDate:expdate];


NSArray *permissions =  [NSArray arrayWithObject:@"publish_stream"];

if(![facbook isSessionValid])
{
[facebook authorize:permissions delegate:self];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜