コード例 #1
0
        private static void CreateTemporaryAccessKeyByToken(IamClient iamClient)
        {
            var createTemporaryAccessKeyByTokenRequest = new CreateTemporaryAccessKeyByTokenRequest()
            {
                Body = new CreateTemporaryAccessKeyByTokenRequestBody()
                {
                    Auth = new TokenAuth()
                    {
                        Identity = new TokenAuthIdentity()
                        {
                            Methods = new List <TokenAuthIdentity.MethodsEnum>()
                            {
                                TokenAuthIdentity.MethodsEnum.TOKEN
                            },
                            Token = new IdentityToken()
                            {
                                Id = "",
                                DurationSeconds = 900
                            }
                        }
                    }
                }
            };

            try
            {
                var createTemporaryAccessKeyByTokenResponse =
                    iamClient.CreateTemporaryAccessKeyByToken(createTemporaryAccessKeyByTokenRequest);
                Console.WriteLine(JsonConvert.SerializeObject(createTemporaryAccessKeyByTokenResponse.Credential));
            }
            catch (RequestTimeoutException requestTimeoutException)
            {
                Console.WriteLine(requestTimeoutException.ErrorMessage);
            }
            catch (ServiceResponseException clientRequestException)
            {
                Console.WriteLine(clientRequestException.HttpStatusCode);
                Console.WriteLine(clientRequestException.ErrorCode);
                Console.WriteLine(clientRequestException.ErrorMsg);
            }
            catch (ConnectionException connectionException)
            {
                Console.WriteLine(connectionException.ErrorMessage);
            }
        }