facebook / facebook/facebook-ios-sdk

Facebook Login getting Error "Safari can't open the page because too many redirects occurred" on iPad

Open
#2,546 8 comments 10 reactions 0 assignees View on GitHub
bug needs-triage
Dominant language
Swift
Stars
8.1k
Forks
3.7k
PR merge metrics
No merged PRs in 30d

Description

### Checklist before submitting a bug report

- [x] I've updated to the latest released version of the SDK
- [x] I've searched for existing [GitHub issues](https://github.com/facebook/facebook-ios-sdk/issues)
- [x] I've looked for existing answers on [Stack Overflow](https://facebook.stackoverflow.com), the [Facebook Developer Community Forum](https://developers.facebook.com/community/) and the [Facebook Developers Group](https://www.facebook.com/groups/fbdevelopers)
- [x] I've read the [Code of Conduct](https://github.com/facebook/facebook-ios-sdk/blob/main/CODE_OF_CONDUCT.md)
- [x] This issue is not security related and can safely be disclosed publicly on GitHub

### Xcode version

16.2

### Facebook iOS SDK version

13.2.0 & 17.1.0

### Dependency Manager

Prebuilt Binaries

### SDK Framework

Login

### Goals

Players can sign in to my app with their Facebook accounts.

### Expected results

Login succeed

### Actual results

Over the past two months, we have been receiving more than 10 daily reports from players who are unable to log into our app via Facebook. Most of these issues occur on iPad devices, spanning iOS versions from 12 to 18, and the total number of affected players has now exceeded 150. I was able to reproduce this issue myself on an iPad mini 2 running iOS 12.5.5. When a player attempts to log in, the Facebook SDK opens Safari to load login.facebook.com, but it gets stuck in an infinite loop of redirections. Eventually, Safari displays the error: "Safari can’t open the page because too many redirects occurred."

I tried switching to a different Facebook App ID and upgraded the SDK to version v17.1.0. I also wrote a minimal example code for Facebook login, but the issue still persists on the same iPad mini 2 device. This suggests that the problem is unrelated to the Facebook App ID or the version of the Facebook iOS SDK. My suspicion is that the issue is specific to certain iPad devices, possibly due to the `login.facebook.com` webpage entering an infinite loop of redirections based on the user agent. When the number of redirections exceeds the limit, Safari stops loading the Facebook webpage altogether.

![Image](https://github.com/user-attachments/assets/6bc24566-24dd-4045-8608-72eb1e7f25d3)

### Steps to reproduce

It seems like the issue is easily reproducible across multiple iPad devices. If you test on several iPads (especially older models or those running specific iOS versions), you might consistently encounter the same problem where the Facebook login process results in an infinite redirection loop and ultimately fails with the "too many redirects" error in Safari.

### Code samples & details

```swift
FBSDKLoginManager *loginMgr = [[FBSDKLoginManager alloc] init];
[loginMgr logOut];

[loginMgr logInWithPermissions: permissions fromViewController:nil handler:^(FBSDKLoginManagerLoginResult * _Nullable result, NSError * _Nullable error) {
if (error) { //login facebook failed

} else if (result.isCancelled) {// Handle cancellations

} else { //login facebook success

}
}];
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.