1

I am trying to use FacebookLogin with Parse however i am receiving an error that,

The supplied Facebook session token is expired or invalid

every time I try to login using the code below.

import Foundation
import UIKit

class LoginViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    let permissions = ["public_profile", "email"]
    PFFacebookUtils.logInWithPermissions(permissions) {
        (user, error) in
        if (user == nil) {
            if (error == nil) {
                println("User cancelled FB login")
            }else{
                println("FB login error: \(error)")
            }
        } else if user.isNew {
            println("User signed up and logged in with Facebook")

        } else {
            println("User logged in via Facebook")

        }
    }
}
Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
coderlyfe
  • 206
  • 1
  • 2
  • 9

1 Answers1

1

I had this error once and had to put this line before the login call in Objective-C

[FBSession.activeSession closeAndClearTokenInformation];

I can't seem to find the swift equivalent in the Parse SDK, and the Facebook SDK is still only in Objective-C.

You may have to add this line to an Objective-C file, and then call on it from your swift file. Check out this question on how to do that

How to call Objective-C code from Swift

Community
  • 1
  • 1
mverderese
  • 5,314
  • 6
  • 27
  • 36