I am trying to push events to Pinpoint using Cognito Identity Pool Anonymous User Credentials, but I am not sure how do I convert BasicSessionCredentials to AwsCredentialsProvider?
I assuming AWS SDKv2 Java
import software.amazon.awssdk.auth.credentials.*;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.cognitoidentity.model.*;
import software.amazon.awssdk.services.cognitoidentity.CognitoIdentityClient;
import software.amazon.awssdk.services.cognitoidentityprovider.model.ExpiredCodeException;
import software.amazon.awssdk.services.pinpoint.PinpointClient;
import software.amazon.awssdk.services.pinpoint.model.*;
import software.amazon.awssdk.utils.ImmutableMap;
CognitoIdentityClient cognitoClient = CognitoIdentityClient.builder().build();
GetIdRequest idRequest = GetIdRequest.builder().identityPoolId(DEFAULT_IDENTITY_POOL_ID).build();
GetIdResponse idResponse = cognitoClient.getId(idRequest);
GetCredentialsForIdentityRequest getCredentialsForIdentityRequest = GetCredentialsForIdentityRequest.builder()
.identityId(idResponse.identityId())
.build();
GetCredentialsForIdentityResponse getCredentialsForIdentityResponse = cognitoClient.getCredentialsForIdentity(getCredentialsForIdentityRequest);
BasicSessionCredentials awsCreds = new BasicSessionCredentials(getCredentialsForIdentityResponse.credentials().accessKeyId(), getCredentialsForIdentityResponse.credentials().secretKey(), getCredentialsForIdentityResponse.credentials().sessionToken());
pinpoint = PinpointClient.builder()
.region(DEFAULT_PINPOINT_REGION)
.credentialsProvider((AwsCredentialsProvider) awsCreds)
.build();
Can someone guide me here building pinpoint client using Cognito Identity Pool Anonymous User Credentials?
Thanks