Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set initial screen using Auth0.swift WebAuth0

Tags:

swift

auth0

I can't find a way to select which screen is to be shown when the Auth0 dialog comes up.

The lock SDK has a withOptions method with a initialScreen option for this specific use case https://auth0.com/docs/libraries/lock-ios/v2/configuration#initialscreen, but there doesn't seem anything for the WebAuth variant.

Parameters looked promising, https://auth0.com/docs/libraries/lock-ios/v1/sending-authentication-parameters, but none of that is actually related to the UI.

Code is fairly straightforward:

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

Using Swift 4.2, Auth0 1.0

like image 671
leopic Avatar asked Jul 09 '18 23:07

leopic


1 Answers

I have used Auth0 in web projects only so far, however, it is very important that you don't mix up the concepts of Auth0's Lock, SDK and API here.

While Lock uses the already implemented and hardly customizable default views of Auth0, the SDK including WebAuth provides the possibility to customize views extensively via defining options in your Auth0 account and sending them alongside with your http requests. See Auth0 - Choose Technology for more information.

I would recommend you to follow the Auth0 Universal Login approach. Create your custom templates with custom options and send those options alongside with your request using WebAuth. As a guideline you could follow this Tutorial - Auth0 QuickStart iOS Login.

like image 84
Michael Andorfer Avatar answered Nov 13 '22 12:11

Michael Andorfer