Retrieve values from the code RRS feed

  • Question

  • Hi 

    I need to get token using Role from AWS S3, How can i retrieve values to string variable from the following code. i found the code from AWS documentation, can you help me.

    My background is SSIS.

     public static Credentials getAssumeRoleSession(String AccessKey, String SecretKey)
                    Credentials sessionCredentials;
                    AmazonSecurityTokenServiceClient client = new AmazonSecurityTokenServiceClient(
                                                              AccessKey, SecretKey,
                                                              new AmazonSecurityTokenServiceConfig());
                    AssumeRoleRequest request = new AssumeRoleRequest
                        DurationSeconds = 3600,
                        RoleArn = "arn:aws:iam::11111166666:role/S3_Read_Only",
                        RoleSessionName = "S3BucketBrowser"
                    AssumeRoleResponse startSessionResponse = client.AssumeRole(request);
                    if (startSessionResponse != null)
                        AssumeRoleResult startSessionResult = startSessionResponse.AssumeRoleResult;
                        sessionCredentials = startSessionResult.Credentials;
                        return sessionCredentials;
                        throw new Exception("S3 Browser ;; Error in retrieving creds");

    Thursday, August 2, 2018 5:46 PM

All replies

  • Which string?

    Your function should return something like this. AccessKeyId, SecretAccessKey and SessionToken are required for your client side part to talk with the server.

    Friday, August 3, 2018 1:25 AM
  • Hi,

    This forum discusses and asks questions about the C# programming language, since your issue is more related to AWS, which is a 3rd-party SDK, I would suggest that you could post your issue on AWS forum for suitable support.


    Best regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, August 3, 2018 5:13 AM