aws-samples/amazon-kinesis-video-streams-webrtc-sdk-js-with-amazon-cognito

Authentication Error on first run

Opened this issue · 0 comments

Hi,

I tried to use this example of AWS Kinesis Video Streams with Cognito, but I am experiencing a problem, where on the first load of the page, the correct credentials result in an authentication error. I am sure that the username and password combination is right because on the second try the same saved credentials work. The problem is mostly reproducible.

In the DevTools, I see the following errors:

After trying to understand the problem, I found this comment in the example code:

var cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);
//console.log(AWS.config.credentials.accessKeyId)
//this is the call where it throws an error in the first run
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function(result) {

The above comment describes the problem very good.

I tried to do some debugging and found out that the onSuccess function in line 43 is reached before the error is produced.

Does anyone know how to fix this error and help others getting started with this tutorial?

Greetings,
Fabio