使用Auth0.swift WebAuth0设置初始屏幕

leo*_*pic 12 swift auth0

当Auth0对话框出现时,我找不到选择显示哪个屏幕的方法.

锁SDK有一个withOptions方法,可以initialScreen选择此特定用例https://auth0.com/docs/libraries/lock-ios/v2/configuration#initialscreen,但WebAuth变体似乎没有任何内容.

参数看起来很有前景,https://auth0.com/docs/libraries/lock-ios/v1/sending-authentication-parameters,但这些都与UI无关.

代码相当简单:

Auth0
  .webAuth(clientId: clientId, domain: domain)
  .scope("openid offline_access")
  .audience(audienceURL)
  .start { result in
    // react on the result...
  }
Run Code Online (Sandbox Code Playgroud)

使用Swift 4.2,Auth0 1.0

Mic*_*fer 2

到目前为止,我只在 Web 项目中使用过 Auth0,但是,这里不要混淆 Auth0 的 Lock、SDK 和 API 的概念,这一点非常重要。

虽然 Lock 使用已经实现且难以自定义的 Auth0 默认视图,但包含 WebAuth 的 SDK 提供了通过在 Auth0 帐户中定义选项并将其与 http 请求一起发送来广泛自定义视图的可能性。请参阅Auth0 - 选择技术了解更多信息。

我建议您遵循Auth0 通用登录方法。使用自定义选项创建自定义模板并使用 WebAuth 将这些选项与您的请求一起发送。作为指导,您可以遵循本教程 - Auth0 QuickStart iOS Login