Authentication Flow
When a user logs in with Facebook, the SDK handles the OAuth flow and returns either an Access Token (traditional login) or an Authentication Token (Limited Login on iOS).Access Tokens
An Access Token is the primary credential used to access Facebook’s Graph API and services. It contains:- Token string: The actual credential used in API calls
- User ID: The Facebook user identifier
- App ID: Your Facebook application identifier
- Permissions: Granted, declined, and expired permissions
- Expiration times: Token expiration and data access expiration
When to Use Access Tokens
- Making Graph API requests
- Accessing user data
- Posting to Facebook
- Traditional Facebook Login flow
Example: Getting Current Access Token
Authentication Tokens (iOS Limited Login)
An Authentication Token is used in iOS Limited Login, which is required when users opt out of App Tracking Transparency (ATT). It’s an OpenID Connect token that provides:- Authentication proof: Verifies the user’s identity
- Nonce: A unique value for validation
- Graph domain: The domain where the user is authenticated
When to Use Authentication Tokens
- iOS apps when user denies ATT permission
- Limited Login flow (iOS only)
- Server-side authentication verification
- Privacy-focused implementations
Example: Getting Authentication Token
Token Lifecycle
Token Expiration
Access tokens have multiple expiration times:- Token expiration: When the token becomes invalid
- Data access expiration: When permission to access data expires
- Last refresh: When the token was last renewed
Token Refresh
You can manually refresh an access token:Listening to Token Changes
Monitor token changes throughout your app:Permissions
Facebook permissions control what data and features your app can access.Permission Types
Read Permissions (requested during login):public_profile- Basic profile informationemail- User’s email addressuser_friends- List of friends who use your appuser_birthday- User’s birthday
publish_actions- Publish content (deprecated)manage_pages- Manage Facebook Pages
Permission States
Permissions can be in three states:- Granted: User approved the permission
- Declined: User denied the permission
- Expired: Permission was granted but has expired
Security Best Practices
Never Store Tokens Client-Side
Validate Tokens Server-Side
For sensitive operations, validate tokens on your server:Use HTTPS Only
Always use HTTPS when transmitting tokens between your app and server.Platform Differences
iOS
- Supports both Access Tokens and Authentication Tokens
- Requires App Tracking Transparency (ATT) for traditional login
- Limited Login available without ATT
- Login behavior is always browser-based
Android
- Only supports Access Tokens
- No ATT requirement
- Multiple login behaviors available:
native_with_fallback(default)native_onlyweb_only
SDK Initialization
Initialize the SDK before attempting authentication:See Also
Login Methods
Learn about different login methods and when to use them
Limited Login
Understand iOS Limited Login for privacy-focused apps
Access Token API
Complete API reference for AccessToken
Authentication Token API
Complete API reference for AuthenticationToken