Search in sources :

Example 1 with GetSessionTokenRequest

use of software.amazon.awssdk.services.sts.model.GetSessionTokenRequest in project aws-doc-sdk-examples by awsdocs.

the class GetSessionToken method getToken.

// snippet-start:[sts.java2.get_session_token.main]
public static void getToken(StsClient stsClient) {
    try {
        GetSessionTokenRequest tokenRequest = GetSessionTokenRequest.builder().durationSeconds(1500).build();
        GetSessionTokenResponse tokenResponse = stsClient.getSessionToken(tokenRequest);
        System.out.println("The token value is " + tokenResponse.credentials().sessionToken());
    } catch (StsException e) {
        System.err.println(e.getMessage());
        System.exit(1);
    }
}
Also used : StsException(software.amazon.awssdk.services.sts.model.StsException) GetSessionTokenResponse(software.amazon.awssdk.services.sts.model.GetSessionTokenResponse) GetSessionTokenRequest(software.amazon.awssdk.services.sts.model.GetSessionTokenRequest)

Aggregations

GetSessionTokenRequest (software.amazon.awssdk.services.sts.model.GetSessionTokenRequest)1 GetSessionTokenResponse (software.amazon.awssdk.services.sts.model.GetSessionTokenResponse)1 StsException (software.amazon.awssdk.services.sts.model.StsException)1