//snippet-sourcedescription:[GetIdentityCredentials.java demonstrates how to retrieve credentials for an Identity in an Identity Pool.]
//snippet-keyword:[Java]
//snippet-sourcesyntax:[java]
// snippet-keyword:[Code Sample]
// snippet-keyword:[Amazon Cognito]
// snippet-service:[cognito]
// snippet-sourcetype:[full-example]
// snippet-sourcedate:[2019-06-22]
// snippet-sourceauthor:[jschwarzwalder (AWS)]
/*
 * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
//snippet-start:[cognito.java2.GetIdentityCredentials.complete]

package com.example.cognito;

//snippet-start:[cognito.java2.GetIdentityCredentials.import]
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.cognitoidentity.CognitoIdentityClient;
import software.amazon.awssdk.services.cognitoidentity.model.GetCredentialsForIdentityRequest;
import software.amazon.awssdk.services.cognitoidentity.model.GetCredentialsForIdentityResponse;
//snippet-end:[cognito.java2.GetIdentityCredentials.import]

public class GetIdentityCredentials {

    public static void main(String[] args) {
        final String USAGE = "\n" +
                "Usage:\n" +
                "    GetIdentityCredentials <identity_pool_id > \n\n" +
                "Where:\n" +
                "    identity_pool_id - The id of an existing identity pool.\n\n" +
                "Example:\n" +
                "    GetIdentityCredentials us-east-2:1234567890112-abcdefgc\n";

        if (args.length < 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String identity_pool_id = args[0];
        //snippet-start:[cognito.java2.GetIdentityCredentials.main]
        CognitoIdentityClient cognitoclient = CognitoIdentityClient.builder().region(Region.US_EAST_1).build();

        GetCredentialsForIdentityResponse response = cognitoclient.getCredentialsForIdentity(GetCredentialsForIdentityRequest.builder()
                .identityId(identity_pool_id)
                .build());

        System.out.println("Identity ID " + response.identityId() + ", Access Key Id " + response.credentials().accessKeyId() );

        //snippet-end:[cognito.java2.GetIdentityCredentials.main]
    }
}
//snippet-end:[cognito.java2.GetIdentityCredentials.complete]

@@ -346,18 +346,17 @@
 te:%5B
-2019-06-22
+4/16/2020
 %5D%0A//
@@ -382,28 +382,20 @@
 or:%5B
-j
 sc
-hwarzwalder (
+macdon-
 AWS
-)
 %5D%0A/*
@@ -412,18 +412,8 @@
 ght 
-2010-2019 
 Amaz
@@ -970,72 +970,8 @@
 %0A */
-%0A//snippet-start:%5Bcognito.java2.GetIdentityCredentials.complete%5D
 %0A%0Apa
@@ -1375,16 +1375,119 @@
 sponse;%0A
+import software.amazon.awssdk.services.cognitoidentityprovider.model.CognitoIdentityProviderException;%0A
 //snippe
@@ -1818,23 +1818,21 @@
 identity
-_pool_i
+PoolI
 d - The 
@@ -2116,23 +2116,21 @@
 identity
-_pool_i
+PoolI
 d = args
@@ -2134,24 +2134,25 @@
 rgs%5B0%5D;%0A
+%0A
         
 //snippe
@@ -2147,181 +2147,395 @@
     
-//snippet-start:%5Bcognito.java2.GetIdentityCredentials.main%5D%0A        CognitoIdentityClient cognitoclient = CognitoIdentityClient.builder().region(Region.US_EAST_1).build();%0A%0A
+CognitoIdentityClient cognitoclient = CognitoIdentityClient.builder()%0A                .region(Region.US_EAST_1)%0A                .build();%0A%0A        getCredsForIdentity(cognitoclient,identityPoolId);%0A    %7D%0A%0A    //snippet-start:%5Bcognito.java2.GetIdentityCredentials.main%5D%0A    public static void getCredsForIdentity( CognitoIdentityClient cognitoclient,String identityPoolId) %7B%0A%0A     try%7B%0A  
     
@@ -2702,23 +2702,21 @@
 identity
-_pool_i
+PoolI
 d)%0A     
@@ -2734,24 +2734,26 @@
 .build());%0A%0A
+  
         Syst
@@ -2866,24 +2866,113 @@
 KeyId() );%0A%0A
+       %7D catch (CognitoIdentityProviderException e)%7B%0A        e.getStackTrace();%0A       %7D%0A
         //sn
@@ -3037,66 +3037,4 @@
 %7D%0A%7D%0A
-//snippet-end:%5Bcognito.java2.GetIdentityCredentials.complete%5D%0A

Update GetIdentityCredentials.java