无需 Web 交互的 IdentityServer 登录

IdentityServer login without web interaction

我目前正在编写一个 Xamarin 应用程序,我希望登录到我的应用程序,这个应用程序使用 IdentityServer 4 进行身份验证。

我希望在 email/password 登录时避免使用任何“网络”界面,但我不确定该怎么做(如果可能的话)。

所以,现在我有一个控制器,其方法如下:

public void LoginAsync(string cliendId, string clientSecret, string email, string password)
{
    // Check the clientId & secrets match
    ....

    // Sign in the user
    var result = await SignInManager.PasswordSignInAsync(email, password, false, true);

    // How to return a token to the Xamarin client here?
}

那么,我有两个问题请教:

谢谢

使用 OpenID Connect,您应该 打开一个新的 Web 界面并让用户通过该页面登录。出于多种原因,创建自己的 login/password 表单并不好。一是用户现在不知道他的凭据将在哪里结束。您的应用程序不应该接触或看到用户 username/password.

如果没有涉及到用户,那么可以看看使用IdentityServer支持的client credentials flow