Skip to main content

Overview

LoginConfiguration describes everything about a single login attempt: which permissions to request, how the SDK should handle tracking, which Messenger page to associate with the request, and the PKCE code verifier to use. You pass a LoginConfiguration to LoginManager.logIn(viewController:configuration:completion:). All initializers are failable. They return nil if any parameter is invalid—for example, if the nonce contains whitespace or the permissions array contains invalid values. Module: FacebookLogin
Declared in: LoginConfiguration.swift
Objective-C name: FBSDKLoginConfiguration

Initializers

init(permissions:tracking:)

The most common initializer. A random UUID is used as the nonce.
public convenience init?(
    permissions: [String],
    tracking: LoginTracking
)
permissions
[String]
Permission strings to request, e.g. ["public_profile", "email"]. Each string must not contain whitespace. Pass an empty array to request no additional permissions.
tracking
LoginTracking
Whether to use .enabled (standard) or .limited tracking. See LoginTracking.

init(permissions:tracking:messengerPageId:authType:)

Creates a configuration associated with a Messenger page and a specific auth type.
public convenience init?(
    permissions: [String],
    tracking: LoginTracking,
    messengerPageId: String?,
    authType: LoginAuthType?
)
permissions
[String]
Permissions to request.
tracking
LoginTracking
Tracking preference for this login attempt.
messengerPageId
String?
The Facebook page ID to associate with this login when using Messenger.
authType
LoginAuthType?
The auth type for this request. Valid values are .rerequest and .reauthorize. Pass nil to omit the parameter. See LoginAuthType.

init(permissions:tracking:messengerPageId:authType:codeVerifier:) (designated)

The full designated initializer with explicit control over all parameters including the PKCE code verifier.
public init?(
    permissions: [String],
    tracking: LoginTracking,
    nonce: String,
    messengerPageId: String?,
    authType: LoginAuthType?,
    appSwitch: AppSwitch,
    codeVerifier: CodeVerifier
)
permissions
[String]
Permissions to request.
tracking
LoginTracking
Tracking preference.
nonce
String
A non-empty alphanumeric string without whitespace used to associate the login attempt with a token. A UUID is generated automatically by the convenience initializers.
messengerPageId
String?
Optional Messenger page ID.
authType
LoginAuthType?
Optional auth type. Accepts .rerequest or .reauthorize only.
appSwitch
AppSwitch
Controls whether the SDK may switch to the Facebook app to complete login.
codeVerifier
CodeVerifier
The PKCE code verifier. If you do not need a specific verifier, use CodeVerifier() to generate one.

Properties

requestedPermissions
Set<FBPermission>
The set of permissions that were requested when this configuration was created.
tracking
LoginTracking
The tracking preference for this login attempt. Defaults to .enabled.
nonce
String
The nonce used for this login attempt. A unique UUID is generated when you use the convenience initializers.
messengerPageId
String?
The Messenger page ID associated with this login request, or nil if not set.
authType
LoginAuthType?
The auth type associated with this login request.
appSwitch
AppSwitch
The app switch behavior to use for this login attempt. Defaults to .enabled.
codeVerifier
CodeVerifier
The PKCE code verifier. Generated automatically if not provided.

LoginTracking enum

CaseDescription
.enabledStandard login with full tracking. The SDK collects analytics and uses access tokens as normal.
.limitedLimited login mode introduced for iOS 14+. Reduces data collection; uses AuthenticationToken instead of AccessToken.
See the Limited Login documentation for a detailed comparison.

LoginAuthType

LoginAuthType is a typed string (NS_TYPED_EXTENSIBLE_ENUM in Objective-C).
ValueDescription
.rerequestRe-requests permissions that were previously declined by the user. This is the default.
.reauthorizeRe-authorizes data access after it has expired. Used internally by reauthorizeDataAccess(from:handler:).

Usage example

import FacebookLogin

// Standard login requesting profile and email
guard let config = LoginConfiguration(
    permissions: ["public_profile", "email"],
    tracking: .enabled
) else {
    print("Invalid configuration")
    return
}

loginManager.logIn(viewController: self, configuration: config) { result in
    // handle result
}

// Limited login (no access token)
guard let limitedConfig = LoginConfiguration(
    permissions: [],
    tracking: .limited
) else { return }

loginManager.logIn(viewController: self, configuration: limitedConfig) { result in
    // handle result — no AccessToken is issued in limited mode
}

Build docs developers (and LLMs) love