public UserCognitoCredentials(Amazon.CognitoIdentity.Model.Credentials credentials) { this.accessKey = credentials.AccessKeyId; this.secretKey = credentials.SecretKey; this.sessionToken = credentials.SessionToken; this.expiration = credentials.Expiration; }
private CredentialsRefreshState GetPoolCredentials() { string text = GetIdentityId(RefreshIdentityOptions.Refresh); GetCredentialsForIdentityRequest getCredentialsForIdentityRequest = new GetCredentialsForIdentityRequest { IdentityId = text }; if (Logins.Count > 0) { getCredentialsForIdentityRequest.Logins = Logins; } if (_identityState != null && !string.IsNullOrEmpty(_identityState.LoginToken)) { getCredentialsForIdentityRequest.Logins = new Dictionary <string, string>(); getCredentialsForIdentityRequest.Logins["cognito-identity.amazonaws.com"] = _identityState.LoginToken; } bool flag = false; GetCredentialsForIdentityResponse getCredentialsForIdentityResponse = null; try { getCredentialsForIdentityResponse = GetCredentialsForIdentity(getCredentialsForIdentityRequest); } catch (AmazonCognitoIdentityException e) { if (!ShouldRetry(e)) { throw; } flag = true; } if (flag) { return(GetPoolCredentials()); } UpdateIdentity(getCredentialsForIdentityResponse.IdentityId); Amazon.CognitoIdentity.Model.Credentials credentials = getCredentialsForIdentityResponse.Credentials; return(new CredentialsRefreshState(credentials.GetCredentials(), credentials.Expiration)); }