Auth0 Home Blog Docs

Swift Auth0 - Safari cannot open the page because the address is invalid

auth0
api
swift

#1

I’m following this tutorial:

I can login to my app in the simulator. On the login screen I click LOGIN WITH GOOGLE. After that I get the error:

Safari cannot open the page because the address is invalid

Info.plist includes:

<key>CFBundleTypeRole</key>
<string>None</string>
<key>CFBundleURLName</key>
<string>auth0</string>
<key>CFBundleURLSchemes</key>
<array>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
</array>

AppDelegate.swift includes:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    
    return true
}

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
    return Auth0.resumeAuth(url, options: options)
}

What am I missing?


#2

The issue was that the URL stuff needed to be nested under CFBundleURLTypes:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>None</string>
        <key>CFBundleURLName</key>
        <string>auth0</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
        </array>
    </dict>
</array>