Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Build Status Coverage Status Swift Version Carthage compatible

Facebook authentication for iOS in pure Swift without any internal dependencies πŸš€



Add the following to your Cartfile:

github "slashkeys/FacebookAuth"


Add the following to your Podfile:

pod 'FacebookAuth'


The main goal of FacebookAuth is it's simple usage. To get started you have to follow these three steps:

1. Create a new FacebookAuth instance

let config = FacebookAuth.Config(appID: "facebookAppID")
let facebookAuth = FacebookAuth(config: config)

2. Configure the instance to handle Facebook responses

In your AppDelegate, add the following method:

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool {
    return facebookAuth.handle(url)

3. Configure your URL schemes

Open your Info.plist as "Source Code" and add the following snippet:


Make sure to replace <YourFacebookAppID> with your Faceboook application ID.

4. Call the authenticate method

Now the only thing left to do is to call authenticate on the FacebookAuth instance and the library should do the rest.

// self is the current `UIViewController`.
facebookAuth.authenticate(onTopOf: self, permissions: [.publicProfile, .email]) { result in
    guard let token = result.token else {
        guard let error = result.error else { return }
        switch error {
        case .cancelled:
            print("The authentication was cancelled by the user.")
        case .failed:
            print("Something else went wrong.")
    guard let permissions = result.granted else { return }
    print("Token \(token) has the following permissions: \(permissions)")

Aksing for permissions

If you need more permissions later you can call the askForPermissions method and pass in the permissions you want to ask for.

facebookAuth.ask(for: [.userBirthday], onTopOf: self) { result in }

You can handle result exactly like above, where result.granted is an array of all permissions granted by the user.

You can’t perform that action at this time.