I have a JavaScript web application that supports Cognito unauthenticated identities. I'm trying to figure out how to identify the linked authenticated IdentityId for a DISABLED
unauthenticated IdentityId.
First unauthenticated users are issued an IdentityId via AWS.config.credentials.get
. Internally CognitoIdentityCredentials
is using getId to generate a new unauthenticated IdentityId.
let unathenticatedIdentityId;
const AWS = require('aws-sdk');
AWS.config.region = region;
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId
});
AWS.config.credentials.get(err => {
unathenticatedIdentityId = AWS.config.credentials.identityId;
});
Then our user authenticates to a Cognito User Pool via amazon-cognito-identity-js
and the unauthenticated IdentityId changes to the authenticated IdentityId associated with their Cognito Login. The unauthenticated IdentityId is automatically marked DISABLED
and is linked internally to the authenticated IdentityId.
let authenticatedIdentityId;
const { CognitoUserPool, CognitoUser, AuthenticationDetails } = require('amazon-cognito-identity-js');
const Pool = new CognitoUserPool({
UserPoolId,
ClientId,
});
const authDetails = new AuthenticationDetails({
Username,
Password,
});
const user = new CognitoUser({
Pool,
Username,
});
user.authenticateUser(authDetails, {
onSuccess: (session) => {
AWS.config.credentials.params.Logins = {
[PoolProviderName]: session.idToken.jwtToken,
};
AWS.config.credentials.expired = true;
AWS.config.credentials.refresh(err => {
authenticatedIdentityId = AWS.config.credentials.identityId;
});
},
});
I have the value for unathenticatedIdentityId
and authenticatedIdentityId
but I do not see a way in the AWS Cognito API's to resolve that the DISABLED
unauthenticatedIdentityId
has been linked to the authenticatedIdentityId
. Conversely I do not see a way to identify what IdentityIds have been linked to the authenticatedIdentityId
. The describeIdentity API will tell me that unauthenticatedIdentityId
is DISABLED
and that it has no Logins
, but it does not point to the linked authenticatedIdentityId
.
How can I, with only the value of the linked/DISABLED unauthenticatedIdentityId
, resolve the value authenticatedIdentityId
?