After importing the AWS-SDK for .NET dll's including the AWS.Extension.CognitoAuthentication into Unity 2018.2, I am having a problem with the StartWithSrpAuthAsync
function taken from AuthenticateWithSrpAsync
provided by https://aws.amazon.com/blogs/developer/cognitoauthentication-extension-library-developer-preview/
Code from site:
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);
}
}
I want a button script to take in a username and password from the user and authenticate it with the UserPool I created in Cognito.
Button Script
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");
}
}
The app client does not require a secret key.
App Client
https://i.stack.imgur.com/lk168.jpg
The User status is confirmed/enabled and the email is verified.
User
https://i.stack.imgur.com/8CT1X.jpg
What ends up happening is the script runs until it gets to:
authResponse = await user.StartWithSrpAuthAsync(new InitiateSrpAuthRequest() {
Password = userPassword
}).ConfigureAwait(false);
Debug.Log(user.SessionTokens.IdToken);
Debug.Log("Success");
And does absolutely nothing afterwards. Neither of the debugs show in the console as well as any Error or warning messages.
Unity Console:
https://i.stack.imgur.com/i2Pb7.jpg
I have looked through the StackOverflow questions as well as every other resource I could find on google. I have also replicated this in Unity 2017.3
I'm using .NetFramework 4.6