in aliyun-net-credentials/Provider/ProfileCredentialsProvider.cs [194:221]
public async Task<CredentialModel> GetSTSAssumeRoleSessionCredentialsAsync(Dictionary<string, string> clientConfig)
{
string accessKeyId = DictionaryUtil.Get(clientConfig, AuthConstant.IniAccessKeyId);
string accessKeySecret = DictionaryUtil.Get(clientConfig, AuthConstant.IniAccessKeyIdsecret);
string roleSessionName = DictionaryUtil.Get(clientConfig, AuthConstant.IniRoleSessionName);
string roleArn = DictionaryUtil.Get(clientConfig, AuthConstant.IniRoleArn);
string regionId = DictionaryUtil.Get(clientConfig, AuthConstant.DefaultRegion);
string policy = DictionaryUtil.Get(clientConfig, AuthConstant.IniPolicy);
if (string.IsNullOrWhiteSpace(accessKeyId) || string.IsNullOrWhiteSpace(accessKeySecret))
{
throw new CredentialException("The configured access_key_id or access_key_secret is empty");
}
if (string.IsNullOrWhiteSpace(roleSessionName) || string.IsNullOrWhiteSpace(roleArn))
{
throw new CredentialException("The configured role_session_name or role_arn is empty");
}
RamRoleArnCredentialProvider provider = new RamRoleArnCredentialProvider.Builder()
.AccessKeyId(accessKeyId)
.AccessKeySecret(accessKeySecret)
.RoleSessionName(roleSessionName)
.RoleArn(roleArn)
.RegionId(regionId)
.Policy(policy)
.Build();
return await provider.GetCredentialsAsync();
}