开发者

Invalid Facebook access token

I am developing an application which posts videos to Facebook. I have registered this app on Facebook, received APIkey, APIsecret, the app successfully passes authentication and receives the access token. Here is my code for authentication:

m_Facebook = [[Facebook alloc] init];
[m_Facebook logout:self];
m_FacebookUploader = [[FBVideoUpload alloc]init]; 
NSArray *permissions =  [NSArray arrayWithObjects:@"publish_stream", @"offline_access",@"read_stream",nil];
m_Facebook.forceOldStyleAuth = YES;
[m_Facebook authorize:kApiKey permissions:permissions delegate:self];

However when trying to upload a video, the class FBVideoUpload tries to separate the access token into several parts:

- (NSString*) sessionID
{
    NSArray *components = [accessToken componentsSeparatedByString:@"|"];
    NSLog(@"components: %@", components);
    return [components count] < 2 ? nil : [components objectAtIndex:1];
}

According to http://developers.facebook.com/docs/authentication/ the access token should contain several componenets, separated by "|", but the one I receive at authentication does not contain several components separated by a "|". The access_token I receive looks as follows:

AAA*GXJapke*BAGRlZC7aBLhiZB*MUEV*AAF6*ZBhZBw*0ER1M*vkXlRUZCwO*czfgs*wHbnA*BcTU*VrPZC*Yw3p*JmCIMZ*xSnCP*GqPRWZALgZDZ*

(I replaced some symbols with "*")

Here 开发者_如何学Pythonis my code for uploading the video:

[m_FacebookUploader setApiKey:kApiKey];
[m_FacebookUploader setAccessToken:m_Facebook.accessToken];
[m_FacebookUploader setAppSecret:kApiSecret];
[m_FacebookUploader startUploadWithURL:url params:params delegate:self];

I receive an error here:

if ([self sessionID] == nil) {
        NSLog(@"Unable to retrieve session key from the access token.");
        return;
    }

Which not surprising since sessionID really returns nil.


Whatever library you're using to do that video upload is using some outdated logic to handle uploads. That whole method where it breaks apart the session key doesn't need to exist. Just use the access token you get back from FB with your video upload request. Also, be sure you're using our latest SDK https://github.com/facebook/facebook-ios-sdk

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜