I authenticate through Cognito in the client-side browser using the authentication authenticated by the developer. When my page loads (or refreshes), I would like my application to remember Identity until the object has expired (I think it lasts about an hour). However, I do not know how to obtain an identity from Cognito without having to re-authenticate the developer.
Here is what the code does when the page loads:
var cognitoCredentials $(document).ready(function() { "use strict"; cognitoParams = { IdentityPoolId: 'us-east-1:xxxxxxx' }; cognitoCredentials = new AWS.CognitoIdentityCredentials(cognitoParams); AWS.config.credentials = cognitoCredentials; });
And after logging in through developer authentication:
cognitoCredentials.params.IdentityId = output.identityId; cognitoCredentials.params.Logins = { 'cognito-identity.amazonaws.com': output.token }; cognitoCredentials.expired = true;
If I have already logged in and then refreshed the page and tried to log in again, I get an error message that I am trying to get an ID when I already have Error: Missing credentials in config(…) NotAuthorizedException: Missing credentials in config "Access to Identity 'us-east-1:xxxxxxx' is forbidden."
However, I do not know how to access it. How do I get credentials so that when I refresh the page, I can find the previous credentials set by Cognito?
source share