auth0を使用してユーザーの詳細を維持しています。私はThis articleに従っています。auth0の接続が見つかりません
デフォルトのロック画面を使用しているプロジェクトをダウンロードしましたが、正常に動作しています。ユーザーとログイン、ログアウトを作成できます。
カスタムログインビューで試してみると、自分の資格情報でログインしようとすると「接続が見つかりません」というエラーが表示されます。
私は確信していますが、ここでどの接続を渡す必要がありますか。
以下、上記の記事から貼り付けたコードです。以下は
[HttpPost]
public async Task<ActionResult> Login(LoginViewModel vm, string returnUrl = null)
{
if (ModelState.IsValid)
{
try
{
AuthenticationApiClient client =
new AuthenticationApiClient(
new Uri($"https://{ConfigurationManager.AppSettings["auth0:Domain"]}/"));
var result = await client.AuthenticateAsync(new AuthenticationRequest
{
ClientId = ConfigurationManager.AppSettings["auth0:ClientId"],
Scope = "openid",
Connection = "Database-Connection", // Specify the correct name of your DB connection
Username = vm.EmailAddress,
Password = vm.Password
});
// Get user info from token
var user = await client.GetTokenInfoAsync(result.IdToken);
// Create claims principal
var claimsIdentity = new ClaimsIdentity(new[]
{
new Claim(ClaimTypes.NameIdentifier, user.UserId),
new Claim(ClaimTypes.Name, user.FullName ?? user.Email),
new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "ASP.NET Identity", "http://www.w3.org/2001/XMLSchema#string")
}, DefaultAuthenticationTypes.ApplicationCookie);
// Sign user into cookie middleware
AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = false }, claimsIdentity);
return RedirectToLocal(returnUrl);
}
catch (Exception e)
{
ModelState.AddModelError("", e.Message);
}
}
return View(vm);
}
あなたが確認する必要があり
[OK]を、私はデータベース名を渡しています"Auth0AuthenticationDB"と私のログインを許可していますが、今私にトークン情報を与えていません。私はロック画面を使用していたときにトークンを取得していました –
働いています..私はログインアクションでclaimsIdentityにトークンを渡します –