Explore Courses Blog Tutorials Interview Questions
0 votes
in AWS by (19.1k points)

I am trying to get temp credentials for AWS from STS using a SAML request(from ADFS). I have the SAML token, the role arn and principalARN. If I use this to login using AWS CLI they work. But using the same 3 with the Java SDK gives the following error.

Unable to load AWS credentials from any provider in the chain

Here is the Java code I am using.

AssumeRoleWithSAMLRequest samlreq =new AssumeRoleWithSAMLRequest().withPrincipalArn(principalARN).withRoleArn(roleARN).withSAMLAssertion(SAMLToken);

AWSSecurityTokenServiceClient stsclient = new AWSSecurityTokenServiceClient();

AssumeRoleWithSAMLResult tempcreds=stsclient.assumeRoleWithSAML(samlreq);

Any idea what I am doing wrong or missing?

Here is the Stack trace:

Exception in thread "main" com.amazonaws.AmazonClientException: Unable to load AWS credentials from any provider in the chain at com.amazonaws.auth.AWSCredentialsProviderChain.getCredentials( at at at App.main(

1 Answer

0 votes
by (44.4k points)

I got it working finally had to add :

BasicAWSCredentials basicCreds=new BasicAWSCredentials("", "");

AWSSecurityTokenServiceClient stsclient = new AWSSecurityTokenServiceClient(basicCreds);   

Basically give the sts client a blank set of credentials.

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.5k questions

29.9k answers


99.1k users

Browse Categories