public static CredentialProfileOptions ExtractProfileOptions(AWSCredentials credentials) { var type = credentials.GetType(); if (type == typeof(BasicAWSCredentials) || type == typeof(SessionAWSCredentials)) { var immutableCredentials = credentials.GetCredentials(); return(new CredentialProfileOptions { AccessKey = immutableCredentials.AccessKey, SecretKey = immutableCredentials.SecretKey, Token = immutableCredentials.Token }); } if (PassThroughExtractTypes.Contains(type)) { return(null); } if (ThrowExtractTypes.Contains(type)) { throw new InvalidOperationException("Cannot save credentials of type " + type.Name); } throw new InvalidOperationException("Unrecognized credentials type: " + type.Name); }