github auth0/Auth0.swift 1.0.0-beta.3

latest releases: 2.7.2, 2.7.1, 2.7.0...
pre-release7 years ago

Full Changelog

Added:

  • Show better error when PKCE is not enabled in client #30 (hzalaz)
  • Auth0 telemetry information #29 (hzalaz)
  • Multifactor support for /oauth/ro #28 (hzalaz)

Changed:

  • Added parameter labels in Authentication API methods #27 (hzalaz)
  • Reworked Error handling #26 (hzalaz)

Breaking changes:

Most of the Authentication API methods first parameters labels are required so for example this call:

Auth0
    .login("mail@mail.com", password: "secret", connection: "connection")

now needs to have the usernameOrEmail parameter label

Auth0
    .login(usernameOrEmail: "mail@mail.com", password: "secret", connection: "connection")

Now all Result object return ErrorType instead of a specific error, this means that OS errors like no network, or connection could not be established are not wrapped in any Auth0 error anymore.

Also the error types that Auth0.swift API clients can return are no longer an enum but a simple object:

  • Authentication API: AuthenticationError
  • Management API: ManagementError

Each of them has it's own values according at what each api returns when the request fails. Now to handle Auth0.swift errors in your callback, you can do the following:

Auth0
    .login(usernameOrEmail: "mail@mail.com", password: "secret", connection: "connection")
    .start { result in
        switch result {
        case .Success(let credentials):
            print(credentials)
        case .Failure(let cause as AuthenticationError):
            print("Auth0 error was \(cause)")
        case .Failure(let cause):
            print("Unknown error: \(cause)")
        }
    }

Also, AuthenticationError has some helper methods to check for common failures:

Auth0
    .login(usernameOrEmail: "mail@mail.com", password: "secret", connection: "connection")
    .start { result in
        switch result {
        case .Success(let credentials):
            print(credentials)
        case .Failure(let cause as AuthenticationError) where cause.isMultifactorRequired:
            print("Need to ask the user for his mfa code!")
        case .Failure(let cause):
            print("Login failed with error: \(cause)")
        }
    }

Don't miss a new Auth0.swift release

NewReleases is sending notifications on new releases.