I'm trying to compile a Signup script using Cognito in Unity, and I'm encountering the following error: 'AmazonCognitoIdentityProviderClient.SignUp(SignUpRequest)' is inaccessible due to its protection level. The error appears when attempting to use the AmazonCognitoIdentityProviderClient's SignUp method in the script.
Any help or guidance on how to resolve this error would be greatly appreciated. Thank you!
using System;
using System.Collections.Generic;
using UnityEngine;
using Amazon.CognitoIdentityProvider;
using Amazon.CognitoIdentityProvider.Model;
using TMPro;
public class Signup : MonoBehaviour
{
private string clientId = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";
public TMP_InputField usernameField;
public TMP_InputField passwordField;
public void OnClick()
{
var client = new AmazonCognitoIdentityProviderClient(null, Amazon.RegionEndpoint.APNortheast1);
var signup_request = new SignUpRequest
{
ClientId = clientId,
Username = usernameField.text,
Password = passwordField.text,
};
try
{
var result = client.SignUp(signup_request);
Debug.Log(result);
}
catch (Exception ex)
{
Debug.LogError(ex);
}
}
}
(Response heavily inspired from this similar answer which you should also read for further understanding)
It all depends on which .NET Framework you're targetting
.NET Standard
In .NET Standard SignUp
is internal only.
There is however a SignUpAsync
that you can use.
.NET 3.5 & 4.5+
In .NET 3.5 there is a public SignUp
. There's also a SignUp
in .NET 4.5+ that you could use.