我正在尝试使用PHP服务器和aws cognito身份在Unity中实现开发人员身份验证的身份。我使用了AWS文档中给出的相同代码:
public class DeveloperAuthenticatedCredentials : CognitoAWSCredentials
{
const string PROVIDER_NAME = "login.xyz.abc";
const string IDENTITY_POOL = "IDENTITY_POOL_ID";
static readonly RegionEndpoint REGION = RegionEndpoint.USEast1;
private string login = null;
public DeveloperAuthenticatedCredentials(string loginAlias)
: base(IDENTITY_POOL, REGION)
{
login = loginAlias;
}
protected override IdentityState RefreshIdentity()
{
IdentityState state = null;
ManualResetEvent waitLock = new ManualResetEvent(false);
MainThreadDispatcher.ExecuteCoroutineOnMainThread(ContactProvider((s) =>
{
state = s;
waitLock.Set();
}));
waitLock.WaitOne();
return state;
}
IEnumerator ContactProvider(Action<IdentityState> callback)
{
WWW www = new WWW("[http://example.com/?username=][1]"+login);
yield return www;
string response = www.text;
JsonData json = JsonMapper.ToObject(response);
string identityId = json["IdentityId"].ToString();
string token = json["Token"].ToString();
IdentityState state = new IdentityState(identityId, PROVIDER_NAME, token, false);
callback(state);
}
}
然后我通过传递参数为这个类创建了对象。然后通过传递凭证调用AddLogin。
DeveloperAuthenticatedCredentials Credentials = new DeveloperAuthenticatedCredentials("qwer");
DAC.AddLogin("login.xyz.abc",token);
在服务器中创建令牌时,会生成标识。当我尝试使用cognito sync同步数据时,会创建一个未经身份验证的身份。我还附上了政策&#34; AmazonCognitoDeveloperAuthenticatedIdentities&#34;同时使用身份池的auth和unauth角色。请帮助我合并正在生成的两个身份。提前谢谢。