Authing DocsDocuments
Concept
workflow
Guides
Development Integration
Application integration
Concept
workflow
Guides
Development Integration
Application integration
Old Version
Development Integration
  • Single Sign-On (SSO)
  • Login component

  • JavaScript/Node.js

  • Java / Kotlin

  • Python

  • C#

  • PHP

  • Go

  • Ruby
  • Android

  • iOS

    • Quick start
    • Auth Flow
    • APIs

    • Third-party identity source

      • Wechat
      • Apple
      • Google
      • Facebook
      • Wechat Miniprogram
      • Tencent
      • Sina Weibo
      • Baidu
      • LinkedIn
      • Github
      • Gitee
      • GitLab
      • Xiaomi
      • WeCom
      • Lark
      • DingTalk
      • Line
      • Slack
    • Typical scene

    • On-premise
    • WebAuthn
    • Error Code List
  • Flutter

  • React Native
  • WeChat Mini Program
  • WeChat webpage authorization
  • Framework Integration
  • Error code
  1. Development Integration
  2. /
  3. iOS
  4. /
  5. Third-party identity source
  6. /
  7. Facebook

¶ Facebook Login

Update Time: 2025-05-14 08:32:28
Edit

¶ Preparation

Configure in Facebook Open Platform (opens new window) and Authing Console (opens new window), please refer to FaceBook Official Documentation (opens new window).


¶ Integrate Facebook Login

¶ Step 1: Add Facebook dependency

  1. Enter: https://github.com/Authing/authing-binary in the swift package search bar.

  2. Select Authing-binary (opens new window).

Authing-binary (opens new window) depends on Guard-iOS SDK (opens new window).

  1. Select Up to Next Major Version 1.0.0 for the dependency rule.

  2. Check Facebook after Add Package.


¶ Step 2: Add a whitelist in Info.plist

  1. Right-click on Info.plist and select Open As ▸ Source Code.

  2. Copy and paste the following XML code snippet into the body of the file.

APP-ID corresponds to the application ID of the Facebook developer background. CLIENT-TOKEN This value can be found in the Facebook Developer Dashboard App Dashboard Settings > Advanced > Client Token. APP-NAME corresponds to the application name of the Facebook developer backend.

Note that fb needs to be concatenated before APP-ID of CFBundleURLSchemes.

<key>CFBundleURLTypes</key>
<array>
   <dict>
   <key>CFBundleURLSchemes</key>
   <array>
     <string>fbAPP-ID</string>
   </array>
   </dict>
</array>
<key>FacebookAppID</key>
<string>APP-ID</string>
<key>FacebookClientToken</key>
<string>CLIENT-TOKEN</string>
<key>FacebookDisplayName</key>
<string>APP-NAME</string>

¶ Step 3: Initialize Facebook Login

import Guard
import Facebook

class AppDelegate: UIResponder, UIApplicationDelegate {
     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
         Authing.start(<#AUTHING_APP_ID#>)
         Facebook.register(application, didFinishLaunchingWithOptions: launchOptions)
     }

     func application(_ app: UIApplication, open url: URL, options: [UIApplication. OpenURLOptionsKey : Any] = [:]) -> Bool {
         if "\(url)". contains(Facebook. getAppId()) {
             return Facebook. application(app, open: url, options: options)
         }
     }
}

¶ Step 4: Initiate Facebook login authorization

¶ Facebook Authorized Login

func login(viewController: UIViewController, completion: @escaping Authing.AuthCompletion) -> Void

parameter

  • viewController AuthViewController hosting the view

example

Facebook.login(viewController: <#ViewController#>) { code, message, userInfo in
     if (code == 200) {
         // login successful
         // userInfo
     }
}

If the developer integrates Facebook login by himself, after getting AccessToken, he can call the following API in exchange for Authing user information:

¶ Login via Facebook Authorization Code

func loginByFacebook(_ accessToken: String, completion: @escaping(Int, String?, UserInfo?) -> Void)

parameter

  • accessToken AccessToken returned by Facebook after successful authorization

example

AuthClient().loginByFacebook(accessToken) { code, message, userInfo in
     // userInfo
}
Prev: Google Next: Wechat Miniprogram
  • Preparation
  • Integrate Facebook Login

User identity management

Integrated third-party login
Mobile phone number flash check (opens new window)
Universal login form component
Custom authentication process

Enterprise internal management

Single Sign On
Multi-factor Authentication
Authority Management

Developers

Development Document
Framework Integration
Blog (opens new window)
GitHub (opens new window)
Community User Center (opens new window)

Company

400 888 2106
sales@authing.cn
16 / F, Block B, NORTH STAR CENTURY CENTER, Beijing(Total)
room 406, 4th floor, zone B, building 1, No. 200, Tianfu Fifth Street, Chengdu(branch)

Beijing ICP No.19051205-1

© Beijing Steamory Technology Co.