Guidance on using sso profile #3318
-
Can you please provide guidance on how to use aws cli sso session with sdk. When using the “newer” sso session verse the legacy (none auto renewing). When I use new way I can’t get the sdk to work in any way.
I get this exception or
this way I get issue with missing assemblies for neither of these work and I guess handful of errors. Is the newer way of sso profile just not support for sdk? I mean it has been around for almost 2 years. It hard as there is no documentation on this. but if i setup the config to use the legacy/older sso sesssion it works fine.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The SDK does support the newer format, there are a couple of documentation pages in our developer guide with examples (and please leave feedback there if you think it can be improved): https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/sso-tutorial-cli-and-app.html The main difference between the example there and your code is that you don't need to use the var chain = new CredentialProfileStoreChain();
chain.TryGetAWSCredentials("default", out AWSCredentials profileCredentials);
using var s3Client = new AmazonS3Client(profileCredentials, RegionEndpoint.EUWest1);
var response = await s3Client.ListBucketsAsync();
Console.WriteLine(response.Buckets.Count); And as you mentioned, you do need to add the |
Beta Was this translation helpful? Give feedback.
The SDK does support the newer format, there are a couple of documentation pages in our developer guide with examples (and please leave feedback there if you think it can be improved): https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/sso-tutorial-cli-and-app.html
The main difference between the example there and your code is that you don't need to use the
SharedCredentialsFile
class,CredentialProfileStoreChain
should be used instead as it retrieves the profile correctly: