Расширение CognitoAuthentication для .NET с проблемой Unity (StartWithSrpAuthAsync())

После импорта AWS-SDK для .NET dll, включая AWS.Extension.CognitoAuthentication, в Unity 2018.2, у меня возникла проблема с функцией StartWithSrpAuthAsync, взятой из AuthenticateWithSrpAsync, предоставленной https://aws.amazon.com/blogs/developer/cognitoauthentication-extension-library-developer-preview/

Код с сайта:

public async void AuthenticateWithSrpAsync()
{
    var provider = new AmazonCognitoIdentityProviderClient(new AnonymousAWSCredentials(),
                                                           FallbackRegionFactory.GetRegionEndpoint());
    CognitoUserPool userPool = new CognitoUserPool("poolID", "clientID", provider);
    CognitoUser user = new CognitoUser("username", "clientID", userPool, provider);

    string password = "userPassword";



    AuthFlowResponse context = await user.StartWithSrpAuthAsync(new InitiateSrpAuthRequest()
    {
        Password = password
    }).ConfigureAwait(false);

}

}

Я хочу, чтобы скрипт кнопки принимал имя пользователя и пароль от пользователя и аутентифицировал их с помощью UserPool, который я создал в Cognito.

Скрипт кнопки

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Amazon;
using Amazon.Runtime;
using Amazon.CognitoIdentityProvider;
using Amazon.Extensions.CognitoAuthentication;


public class test : MonoBehaviour {

public string userName;
public string userPassword;
public string clientID;
public string poolID;


public AuthFlowResponse authResponse;
public CognitoUserPool userPool;
public AmazonCognitoIdentityProviderClient provider;
public CognitoUser user;

void Start()
{

}
public void OnClick()
{
    try
    {
        AuthenticateWithSrpAsync();
    }
    catch(Exception ex)
    {
        Debug.Log(ex);
    }

}

public async void AuthenticateWithSrpAsync()
{
    RegionEndpoint CognitoIdentityRegion = RegionEndpoint.USEast1;
    provider = new AmazonCognitoIdentityProviderClient(null, CognitoIdentityRegion);
    userPool = new CognitoUserPool(poolID, clientID, provider, null);
    user = new CognitoUser(userName, clientID, userPool, provider);
    string name = user.Username.ToString();
    Debug.Log(name);
    authResponse = await user.StartWithSrpAuthAsync(new InitiateSrpAuthRequest() {

        Password = userPassword

    }).ConfigureAwait(false);
    Debug.Log(user.SessionTokens.IdToken);
    Debug.Log("Success");
}

}

Клиент приложения не требует секретного ключа.

Клиент приложения

https://imgur.com/a/NUzBghb

Статус пользователя подтвержден/включен, а электронная почта подтверждена.

Пользователь

https://imgur.com/lsnG5tT

В итоге происходит то, что скрипт работает до тех пор, пока не доберется до:

authResponse = await user.StartWithSrpAuthAsync(new InitiateSrpAuthRequest() {

    Password = userPassword

}).ConfigureAwait(false);
Debug.Log(user.SessionTokens.IdToken);
Debug.Log("Success");

И вообще ничего потом не делает. Ни одна из отладок не отображается в консоли, а также сообщения об ошибках или предупреждения.

Консоль единства:

https://imgur.com/Hxpcmoj

Я просмотрел вопросы StackOverflow, а также любой другой ресурс, который смог найти в Google. Я также повторил это в Unity 2017.3.

Я использую .NetFramework 4.6.


person Kevin Amditis    schedule 26.07.2018    source источник


Ответы (2)


Попробуйте установить флажок «Включить имя пользователя-пароль (не-SRP)... показанный на изображении в ссылке https://imgur.com/a/NUzBghb.

person user3378643    schedule 27.07.2018
comment
К сожалению, ничего не изменилось, когда я это сделал - person Kevin Amditis; 27.07.2018

Я не думаю, что это связано с Unity, так как у меня тот же код работает нормально. Можете ли вы попробовать следующее: _provider = new AmazonCognitoIdentityProviderClient(new AnonymousAWSCredentials(), );

person user3378643    schedule 02.08.2018