[英]Unable to load AWS credentials from any provider in the chain - kinesis-kafka-connector
[英]STS ,SAML and Java SDK Unable to load AWS credentials from any provider in the chain
我正在嘗試使用SAML requet(來自ADFS)從STS獲取AWS的臨時憑證。 我有SAML令牌,角色arn和principalARN。 如果我使用它來使用AWS CLI登錄它們就可以了。 但是使用與Java SDK相同的3會產生以下錯誤。
無法從鏈中的任何提供程序加載AWS憑據
這是我正在使用的Java代碼。
AssumeRoleWithSAMLRequest samlreq =new AssumeRoleWithSAMLRequest().withPrincipalArn(principalARN).withRoleArn(roleARN).withSAMLAssertion(SAMLToken);
AWSSecurityTokenServiceClient stsclient = new AWSSecurityTokenServiceClient();
AssumeRoleWithSAMLResult tempcreds=stsclient.assumeRoleWithSAML(samlreq);
知道我做錯了什么或錯過了嗎?
這是堆棧跟蹤:
線程“main”中的異常com.amazonaws.AmazonClientException:無法從com.amazonaws.auth.AWSCredentialsProviderChain.getCredentials(AWSCredentialsProviderChain.java:117)鏈中的任何提供者加載AWS憑證,地址為com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient .invoke(AWSSecurityTokenServiceClient.java:1098)位於App.main的com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient.assumeRoleWithSAML(AWSSecurityTokenServiceClient.java:575)(App.java:83)
我得到它的工作最后不得不添加:
BasicAWSCredentials basicCreds=new BasicAWSCredentials("", "");
AWSSecurityTokenServiceClient stsclient = new AWSSecurityTokenServiceClient(basicCreds);
基本上給sts客戶端一組空白的憑據。
不推薦使用AWSSecurityTokenServiceClient。 以下代碼也有效。
BasicAWSCredentials theAWSCredentials= new BasicAWSCredentials("","");
AWSCredentialsProvider theAWSCredentialsProvider = new AWSStaticCredentialsProvider(theAWSCredentials);
AWSSecurityTokenService theSecurityTokenService = AWSSecurityTokenServiceClientBuilder.standard().withCredentials(theAWSCredentialsProvider).build();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.