我正在尝试在 asp.net Core 2 上登录用户服务器端
我已经注册了一个用户并通过验证链接进行了确认,但现在我正在努力将该用户登录到我的应用程序中。很遗憾,c# 的文档太差了!
用户池配置:
应用程序客户端:为基于服务器的身份验证启用登录 API (ADMIN_NO_SRP_AUTH) - 选中
这是代码:
public async Task<bool> SignInUserAsync(CognitoUser user)
{
var provider = new AmazonCognitoIdentityProviderClient(new AnonymousAWSCredentials(),
RegionEndpoint.GetBySystemName("eu-west-2"));
try
{
var authReq = new AdminInitiateAuthRequest
{
AuthFlow = AuthFlowType.ADMIN_NO_SRP_AUTH,
UserPoolId = _poolId,
ClientId = _clientId
};
authReq.AuthParameters.Add("USERNAME", user.Email);
authReq.AuthParameters.Add("PASSWORD", user.Password);
AdminInitiateAuthResponse authResp = await provider.AdminInitiateAuthAsync(authReq);
return true;
}
catch
{
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
返回的错误是Missing Authentication Token但我无法确定需要设置/已给我的令牌的位置。
是我的AmazonCognitoIdentityProviderClient设置还是应用程序客户端设置下的
AWS > User Pools > App Intergration > …
c# amazon-web-services amazon-cognito asp.net-core aws-cognito