2017-06-27 124 views
0

我登記在Auth0用戶登錄(在儀表板的用戶選擇) 我用下面的代碼來認證用戶(具有用戶名和密碼一個HTML表格)Auth0登錄認證

public login(username: string, password: string): void { 
    this.auth0.redirect.loginWithCredentials({ 
     connection: 'Username-Password-Authentication', 
     username, 
     password 
    }, err => { 
     if (err) return alert(err.description); 
    }); 
    } 

,它完美運作。 但是,由於redirect.loginWithCredentials的棄用,我想使用client.login,但它不起作用。這是我的代碼

this.auth0.client.login({ 
     realm: 'Database', 
     grant_type: 'http://auth0.com/oauth/grant-type/password-realm', 
     username, 
     password, 
     scope: 'openid profile', 
    }, err => { 
     if (err) return alert(err.description); 
    }); 

我認爲問題是領域的名稱。使用我在Auth0中創建的用戶的領域名稱是什麼?

謝謝所有

+0

有助於瞭解您正在使用的auth0.js庫的版本。你有沒有嘗試把你的數據庫連接的名稱作爲領域價值,即。用戶名密碼認證(在這裏發表評論,而不是一個答案,因爲我沒有明確檢查) – arcseldon

+0

感謝它是v 8.8.0 –

+0

嗨,我的答案下面解決您的問題? – arcseldon

回答

0

應該設置爲連接名稱。見here

在你的情況下,嘗試設置爲Username-Password-Authentication

從文檔:

設置新的請求參數境界用戶所屬的領域。 這映射到Auth0中的連接。例如,如果您有 爲您的內部員工配置了數據庫連接,並且您的 已命名連接員工,則使用此值。