Привет, ребята, новички в Xamarin Forms и AWS.Я создал страницу входа в приложение, но всякий раз, когда я пытаюсь войти, я получаю сообщение «Identity» us-east1-xxxxxxxxxxxxxxxxx »not found. Я не знаю, в чем причина этой ошибки. Я пытался создать пул пользователей и Identity Pool вДругой регион тоже, но не повезло. Я поражен на этом этапе. Если кто-нибудь может мне помочь, это было бы здорово.
Файл MainWindow.xaml.cs выглядит так:
using Amazon;
using Amazon.Runtime;
using Amazon.CognitoIdentityProvider;
using Amazon.CognitoIdentityProvider.Model;
using System.Threading.Tasks;
using System.Configuration;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using Amazon.CognitoIdentity;
using System;
namespace YouBook
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MainWindow : ContentPage
{
private readonly static string poolId = "us-east-1:edxxxxxxxxxxxxxxxxxxxxxxx";
private readonly static string accountId = "xxxxxxxxxxxxxxxxxx";
private readonly static string unAuthArn = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
private readonly static string clientId = "xxxxxxxxxxxxxxxxxxxxxxxx";
private readonly static CognitoAWSCredentials credentials = new CognitoAWSCredentials(accountId, poolId, unAuthArn, null, RegionEndpoint.USEast1);
private readonly AmazonCognitoIdentityProviderClient _client = new AmazonCognitoIdentityProviderClient(credentials, RegionEndpoint.USEast1);
public MainWindow ()
{
InitializeComponent ();
}
private void SignUpButton_Click(object sender, EventArgs e)
{
SignUp signUpDlg = new SignUp(_client);
//signUpDlg.ShowDialog();
App.Current.MainPage = new SignUp(_client);
}
private async void LoginButton_Click(object sender, EventArgs e)
{
bool loggedIn = await CheckPasswordAsync(UserNameTextBox.Text, PasswordTextBox.Text);
if (loggedIn == true)
App.Current.MainPage = new NavigationPage();
else
await DisplayAlert("Alert", "Couldn't Login. Please Try Again!", "OK");
}
private async Task<bool> CheckPasswordAsync(string userName, string password)
{
try
{
var authReq = new AdminInitiateAuthRequest()
{
UserPoolId = poolId,
ClientId = clientId,
AuthFlow = AuthFlowType.ADMIN_NO_SRP_AUTH
};
authReq.AuthParameters.Add("USERNAME", userName);
authReq.AuthParameters.Add("PASSWORD", password);
AdminInitiateAuthResponse authResp = await _client.AdminInitiateAuthAsync(authReq);
return true;
}
catch (Exception ex)
{
await DisplayAlert("Alert", "Couldn't Login. " + ex.Message, "OK");
return false;
}
}
}
}