Swift - Embedded Login - Getting the sample code running

Hi Everybody,

I am just getting started with Auth0, building a native client in Swift.
I am using Xcode 9.2. I am running the app on a simulator,
The SDK versions are standard ones from the example:

**target 'Auth0Sample' do**
** pod 'Lock', '~> 2.2'**
** pod 'Auth0', '~> 1.5'**
**end**

I am trying to run the embedded login sample

I have created two users, and I have verified their email. I am also sure I am using the right password.
I created an Auth0.plist file ( the sample does not come with one) and verified my domain and ClientID are correct.

I only have one client, which is set to ā€œNativeā€ and I have set the callback url to
auth0.samples.Auth0Sample://mrschulz.auth0.com/ios/auth0.samples.Auth0Sample/callback

When I run the app and login with these users ( not social, my app is enterprise and needs database users) I get a ā€œWeā€™re sorry, something went wrong trying to loginā€. In my output I see this:

-canOpenURL: failed for URL: "org-appextension-feature-password-management://" - error: "This app is not allowed to query for scheme org-appextension-feature-password-management"

So I searched for this, and discovered I need to permit this scheme to my info.plist file. Fine. I add this:

   <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>org-appextension-feature-password-management</string>
    </array>

that just changes the previous error to:

-canOpenURL: failed for URL: "org-appextension-feature-password-management://" - error: "The operation couldnā€™t be completed. (OSStatus error -10814.)"

Am I barking up the wrong tree with these plist entries?
What have I missed that would cause this example to fail ?

The error you reported is a non-issue and is documented here

However, to investigate ā€œWeā€™re sorry, something went wrong trying to loginā€ you can enable debug logging which will show the API call request/response. Setup Logging

2 Likes

Hi Walsh, Thanks for getting back to me.

After some investigation, I am not going to use Lock. This is an enterprise app with itā€™s own ui.
Iā€™m porting an Android App, actually, and from reading their code I see I need to be using Auth0.

The Android code does this (after making a client with domain and clientID)

  client.login(userId, password)
                .start(new AuthenticationCallback() {
                    @Override
                    public void onSuccess(UserProfile userProfile, Token token) {
                        // do success stuff
                    }

                    @Override
                    public void onFailure(Throwable throwable) {
                       // show an alert
                    }
                });
    }

ā€“

Looking at Auth0 (Swift) the login sample they give seems to be deprecated.

What would the equivalent swift code look like?
Do I need to know about realms, audiences and scope? the android login specifies none of these.

A good start placing for these is to look at the QuickStarts

Also

The quick starts should be more clear about what ā€˜realmsā€™ etc are.

Why deprecate a straight forward username/password api for something more complex, is my real question.