如何在Windows应用程序(winform)c#中从cognito获取用户令牌。预先感谢。
我试过了
Amazon.CognitoIdentityProvider.AmazonCognitoIdentityProviderClient provider = new Amazon.CognitoIdentityProvider.AmazonCognitoIdentityProviderClient(
new Amazon.Runtime.AnonymousAWSCredentials(), Amazon.RegionEndpoint.USEast1);
userPool = new CognitoUserPool("", "", provider)
AWS 开发工具包代码示例库中有一个 C# 示例,演示了如何使用用户池。您可以克隆存储库并自行运行示例。那里有一个管理员登录部分,与您进行用户(非管理员)登录时所需的类似。此设置使用身份验证质询,如果您不使用该选项,则可以忽略该质询。
public async Task<InitiateAuthResponse> InitiateAuthAsync(string clientId, string userName, string password)
{
var authParameters = new Dictionary<string, string>();
authParameters.Add("USERNAME", userName);
authParameters.Add("PASSWORD", password);
var authRequest = new InitiateAuthRequest
{
ClientId = clientId,
AuthParameters = authParameters,
AuthFlow = AuthFlowType.USER_PASSWORD_AUTH,
};
var response = await _cognitoService.InitiateAuthAsync(authRequest);
Console.WriteLine($"Result Challenge is : {response.ChallengeName}");
return response;
}