Search code examples
iosswiftfacebookfacebook-login

Facebook iOS SDK login error (Invalid Scopes: public_profile, openid.)


I receive the follow error when trying to login using the iOS Facebook SDK:

Invalid Scopes: public_profile, openid.

I have followed the instructions from here which has resulted in this set up:

info.plist

<plist version="1.0">
<dict>
    ...
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLName</key>
            <string></string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>GOOGLE_URL_SCHEME</string>
                <string>fbMY_FB_APP_ID</string>
            </array>
        </dict>
    </array>
    <key>FacebookAppID</key>
    <string>MY_FB_APP_ID</string>
    <key>FacebookClientToken</key>
    <string>MY_FB_CLIENT_TOEN</string>
    <key>FacebookDisplayName</key>
    <string>MY_FB_APP_NAME</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbauth2</string>
        <string>fbapi</string>
        <string>fb-messenger-share-api</string>
    </array>
</dict>
</plist>

AppDelegate.swift

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    FirebaseApp.configure()
    ApplicationDelegate.shared.application( application, didFinishLaunchingWithOptions: launchOptions )
    return true
}

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]
 ) -> Bool {
    return ApplicationDelegate.shared.application(app, open: url, sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplication.OpenURLOptionsKey.annotation])
 } 

Login snippet

let loginManager = LoginManager()
loginManager.logIn(permissions: ["public_profile"], from: self) { result, error in
    if let error = error {
        print("FB Error: \(error)")
    } else if let result = result, result.isCancelled {
        print("FB Cancelled")
    } else {
        print("FB Logged In")
    }
}

I am on iOS 16.2 using the facebook-ios-sdk version 15.1.0. The same error occurs with FB app in live and development mode. I receive the same error on the simulator and device. I can successfully login on the web when using the FB app JS library. I believe I have followed the instructions correctly. What am I missing?

Edit: Settings Screenshots

FB Screen Shot 1 FB Screen Shot 2 FB Screen Shot 3 FB Screen Shot 4 FB Screen Shot 5

Edit:

So I just downloaded this sample from the facebook-ios-sdk. Added my FB App Id to the FacebookAppID field and URL Schemes in the plist. Added the FB Client Token to the plist and updated the bundle identifier to the one listed in the Facebook app, but I get the same error when I run the sample. What the hell is going on? The issue must be in the Facebook app set up, but where? I can't find this issue reported anywhere on the net. Surely someone has seen this before.

enter image description here


Solution

  • I figured it out. I was missing the facebook login from my facebook app products. I found it by accident and now I can login successfully.