简体   繁体   English

在 iphone sdk 中向有效用户 session 请求扩展权限

[英]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.我的 iphone 应用程序正在使用 facebook sdk 实现标准 facebook 连接功能。 in the first step only the offline_access permission is asked to the user.在第一步中,只向用户询问offline_access 权限。

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 class 的相同“授权:委托:”方法来请求扩展权限,唯一的区别是我正在设置 Z26CAE7718C32180A7A50F8 的第一个值的 accessToken 和 expireDate 属性。验证:

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 the new permissions.这可以正常工作,除了某些情况:在请求新权限之前,可能会向用户显示一个新的登录对话框。

This is a problem for my implementation because the user may potentially login with different credentials and broke my session.这对我的实现来说是个问题,因为用户可能使用不同的凭据登录并破坏了我的 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];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM