amazon-archives / aws-sdk-unity

ARCHIVED: The aws sdk for unity is now distributed as a part of aws sdk for dotnet:
https://github.com/aws/aws-sdk-net
Other
105 stars 43 forks source link

How do you extend the CognitoAWSCredentials class for developer IDs? #96

Closed citiusaltius closed 9 years ago

citiusaltius commented 9 years ago

Hey,

In Unity, I understand how the CognitoAWSCredentials works with Facebook, Twitter, or any other largely supported service. In extending CognitoAWSCredentials for developer identities, however, I'm facing a few problems - namely, that calling RefreshIdentity() has a problem with "Network in game thread", and the async callbacks seem to be also having issues.

Do you have any examples for extending CognitoAWSCredentials for developer authenticated identities? Here's what I've been using so far. Thanks!

    public class CustomCognitoCredentials : Amazon.CognitoIdentity.CognitoAWSCredentials
    {

    private string Email { get; set; }
    private string Password { get; set; }
    private string DeviceId { get; set; }

    private static object refreshIdLock = new object();

    public CustomCognitoCredentials() : base(
            Defines.Global.AccountId,
            Defines.Global.CognitoIdentityPoolId,
            Defines.Global.CognitoUnauthRoleArn, Defines.Global.CognitoAuthRoleArn,
            new Amazon.CognitoIdentity.AmazonCognitoIdentityClient(new Amazon.Runtime.AnonymousAWSCredentials(), Defines.Global.CognitoIdentityRegion),
            new Amazon.SecurityToken.AmazonSecurityTokenServiceClient(new Amazon.Runtime.AnonymousAWSCredentials(), Defines.Global.CognitoIdentityRegion))
    {
        DeviceId = UnityEngine.SystemInfo.deviceUniqueIdentifier;
    }

    public void SetEmailAndPassword(string Email, string Password)
    {
        this.Email = Email;
        this.Password = Password;

    }

    public new IdentityState RefreshIdentity()
    {
        SimpleJSON.JSONNode ParsedBody = GetIdAndToken();

        return new IdentityState(ParsedBody["IdentityId"], Defines.Global.CognitoDeveloperProvider, ParsedBody["OpenIdToken"], false);

    }
    }
karthiksaligrama commented 9 years ago

take a look at the developer authenticated id's sample for Unity

http://docs.aws.amazon.com/cognito/devguide/identity/developer-authenticated-identities/?platform=unity

karthiksaligrama commented 9 years ago

Assuming fixed so closing this issue. please feel free to reopen if there is anything else