Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (5.6k points)
edited by

I'm have an application running where I'm getting a temporary  Access key and Secret key followed by a Session token. And now I want to create button in my application so that when I log in there will a button that will enable the users to access the AWS Services like S3.

I'm trying it with Java, but it's not working. Providing my code below:

 GetFederationTokenRequest getFederationTokenRequest = 

  new GetFederationTokenRequest();

getFederationTokenRequest.setDurationSeconds(1800);

getFederationTokenRequestet.getName("UserName");

// A sample policy for accessing Amazon Simple Notification Service (Amazon SNS) in the console.

String policy = "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sns:*\"," +

  "\"Effect\":\"Allow\",\"Resource\":\"*\"}]}";

getFederationTokenRequest.setPolicy(policy);

Any Help?

1 Answer

0 votes
by (12.4k points)

You can get AWS console URL from temporary credentials by retrieving a Token from the endpoint.

So first create a JSON object with the temporary credentials:

{

  "sessionId": "<aws access key id>",

  "sessionKey": "<aws secret access key>",

  "sessionToken": "<aws session token>"

}

Use this JSON as value for Session parameter in the below URL:

https://signin.aws.amazon.com/federation?Action=getSigninToken&Session=<the JSON object>

Now JSON response will look like this,

{

  "SigninToken":"VsPfcblaC....."

}

And sue the Sign in Token value in the URL and it will open the console:

https://signin.aws.amazon.com/federation?Action=login&Destination=https://console.aws.amazon.com/&SigninToken=<SigninToken>

In destination, you can specify the service like aws ec2 or S3.

Interested in learning AWS? Check out: aws certification training.

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

+4 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 2, 2019 in AWS by Amyra (12.9k points)

Browse Categories

...