User Pools for Amazon Cognito - CredentialsError: Missing credentials in config

前端 未结 2 1681
逝去的感伤
逝去的感伤 2020-12-17 19:25

I am trying to create a Web App Authentication with help of this tutorial. Here is the code I have written -

var app = {};

app.configureCognito = function(         


        
2条回答
  •  遥遥无期
    2020-12-17 19:53

    I got it resolved by using below code apparently, there's no need to provide IdentityPoolId in this example at all, these are just the placeholders which can be left as below -

    AWS.config.region = 'us-east-1'; // Region
    AWS.config.credentials = new AWS.CognitoIdentityCredentials({
        IdentityPoolId: '...'
    });
    
    AWSCognito.config.region = 'us-east-1';
    AWSCognito.config.credentials = new AWS.CognitoIdentityCredentials({
        IdentityPoolId: '...' 
    });
    

    And both of the credential AWS.config.credentials and AWSCognito.config.credentials need to be set. Once the above steps complete the AWSCognito.config needs to be updated as below -

    // Need to provide placeholder keys unless unauthorised user access is enabled for user pool
    AWSCognito.config.update({accessKeyId: 'anything', secretAccessKey: 'anything'})
    
    var poolData = { 
        UserPoolId : 'user pool id collected from user pool',
        ClientId : 'application client id of app subscribed to user pool'
    };
    

    dataPhoneNumber and userData are optional, dataPhoneNumber should be provided in case sms verification for signup is required.

    The problem was resolved once the above were in place, Identity-Code is a working model if anyone want to have a look at it.

提交回复
热议问题