Exemplo n.º 1
0
        public void ConvertFromUnixEpochMilliseconds()
        {
            // Sample UTC value: 9/8/2020 18:48:34.970
            var expectedDateTime = new DateTime(2020, 9, 8, 18, 48, 34, DateTimeKind.Utc).AddMilliseconds(970);
            var dateTime         = AWSSDKUtils.ConvertFromUnixEpochMilliseconds(1599590914970).ToUniversalTime();

            Assert.AreEqual(expectedDateTime, dateTime);
        }
Exemplo n.º 2
0
        public static async Task <ImmutableCredentials> CredentialsFromSsoAccessTokenAsync(IAmazonSSO client, string accountId,
                                                                                           string roleName, string accessToken,
                                                                                           IDictionary <string, object> additionalProperties)
        {
            var request = new GetRoleCredentialsRequest()
            {
                AccessToken = accessToken,
                AccountId   = accountId,
                RoleName    = roleName,
            };

            InternalSDKUtils.ApplyValues(request, additionalProperties);

            var response = await client.GetRoleCredentialsAsync(request).ConfigureAwait(false);

            DateTime credentialsExpiration =
                AWSSDKUtils.ConvertFromUnixEpochMilliseconds(response.RoleCredentials.Expiration);

            return(new SSOImmutableCredentials(
                       response.RoleCredentials.AccessKeyId,
                       response.RoleCredentials.SecretAccessKey,
                       response.RoleCredentials.SessionToken,
                       credentialsExpiration));
        }