2017-09-03 116 views
0

我用Auth0網絡登錄設置了一個Swift應用程序,一切正常。然後,我嘗試實施「鎖定」登錄,結果社交媒體登錄效果非常好,但我無法通過用戶名 - 密碼方法登錄。驗證碼「鎖定」爲Swift用戶名密碼登錄不起作用

在我的Auth0數據庫上,註冊用戶出現(表示註冊新用戶名-passoword用戶實際工作)並在Auth0主頁上測試登錄本身也能正常工作。就在嘗試使用Lock小部件登錄時,我收到一個錯誤:「我們很抱歉,嘗試登錄時出錯了。」我也嘗試驗證註冊的電子郵件,但那也沒有解決問題。 任何想法,這裏可能會出現什麼問題?

回答

0

在將該問題指向Auth0/Lock支持之後,找到了解決方案。也許這可以幫助人,有同樣的問題:當使用一些VC裏面的鎖客戶端:

Lock 
     .classic() 
     .withOptions { 
      $0.scope = "openid profile" 
      $0.oidcConformant = true 
      $0.logHttpRequest = true 
     } 
     .withStyle { 
      $0.title = "App Name" 
     } 
     .onAuth { credentials in 
      print("successful login") 
     } 
     .onError { error in 
      print("Failed with error \(error)") 
     } 
     .present(from: self) 

,而不是Web登錄:

Auth0 
.webAuth() 
.audience("https://alienbash.eu.auth0.com/userinfo") 
.start { 
    switch $0 { 
    case .failure(let error): 
     // Handle the error 
     print("Error: \(error)") 
    case .success(let credentials): 
     // Do something with credentials e.g.: save them. 
     // Auth0 will automatically dismiss the hosted login page 
     print("Credentials: \(credentials)") 
    } 

} 

一個必須確保改變「Grant_Type」的Auth0客戶端設置也允許「密碼」授予。爲了做到這一點,在你Auth0客戶端去:

Settings --> Advances Settings --> Grant Types

,並確保檢查鎖定‘「密碼,因爲這勾選默認情況下,創建一個新的Auth0客戶端時和使用時,將不可避免取消選中’客戶端 enter image description here