1

我正在使用v4.8Facebook iOS SDK 并为iOS 8+. 我也在使用v1.11.0Parse 框架

我想通过ACAccount&ACAccountStore类访问 Facebook。登录工作完美,但在我获得访问权限后,我需要将其转换ACAccountFBSDKAccessToken才能登录 Parse 框架:

这是我的 Swift 代码:

let accountStore = ACAccountStore()
let socialAccount = accountStore.accountTypeWithAccountTypeIdentifier(ACAccountTypeIdentifierFacebook)

let appID = NSBundle.mainBundle().infoDictionary?["FacebookAppID"] as? String ?? ""
let permissions = ["user_birthday", "user_relationships", "user_location", "user_about_me"]

accountStore.requestAccessToAccountsWithType(socialAccount, options: [ACFacebookAppIdKey: appID, ACFacebookPermissionsKey: permissions]) {
    (granted: Bool, error: NSError!) in

    var token: FBSDKAccessToken? = nil

    if let socialAccount = accountStore.accountsWithAccountType(socialAccount).last as? ACAccount, let userID = socialAccount.username where granted {
        token = FBSDKAccessToken(tokenString: socialAccount.credential.oauthToken, permissions: permissions, declinedPermissions: nil,
            appID: appID, userID: userID, expirationDate: NSDate.distantFuture(), refreshDate: NSDate.distantFuture())
    }

    if let token = token {
        print("token \(token.tokenString) \(token.permissions) \(token.appID) \(token.userID) \(token.expirationDate) \(token.refreshDate)")
        PFFacebookUtils.logInInBackgroundWithAccessToken(token, block: nil)
    }
}

我收到此错误:error: Parse::InvalidSessionError (Code: 251, Version: 1.11.0)

我究竟做错了什么?

4

0 回答 0