aliyun-openapi-net-sdk icon indicating copy to clipboard operation
aliyun-openapi-net-sdk copied to clipboard

fix(sts): Fix the problem that the HttpResponse returned by getting STS is null

Open zhenlei520 opened this issue 3 years ago • 2 comments

zhenlei520 avatar May 17 '22 05:05 zhenlei520

AlibabaCloudCredentialsProvider provider = new AccessKeyCredentialProvider("<your-access-key-id>", "<your-access-key-secret>");
IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou");
DefaultAcsClient client = new DefaultAcsClient(profile, provider);

var request = new AssumeRoleRequest
{
    RoleArn = "<your-role-arn>",
    RoleSessionName = "<your-role-session-name>",
    DurationSeconds = 3600
};
try
{
    var response = client.GetAcsResponse(request);
    Assert.IsNotNull(response.HttpResponse);// Tip: The value of HttpResponse obtained here is null
    Console.WriteLine(System.Text.Encoding.Default.GetString(response.HttpResponse.Content));
}
catch (ServerException e)
{
    Console.WriteLine(e);
}
catch (ClientException e)
{
    Console.WriteLine(e);
}

zhenlei520 avatar May 17 '22 06:05 zhenlei520

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar May 17 '22 06:05 CLAassistant