简体   繁体   中英

Cognito UnknownError after turn on device registration

As per requirement, I need to turn on device registration to Always . However, our SRP flow starts failing with the below issue.

{ code: 'UnknownError', message: 'Unknown error, the response body from fetch is: undefined' }

After doing some research, I found one similar post , but it seems like the only solution is to turn device registration off.

It's failing while running node get-token.js script to retrieve token for our CI/CD testing pipeline.

    cognitoUser.authenticateUser(authCfg, {
        onSuccess: function (result) {
            console.log("Result : ", result);
            const token = result.getAccessToken().getJwtToken();
            resolve(token)
        },
        onFailure: function(err) {
            console.error("Failure : ", err);
            console.log(new Error().stack);
            reject(new Error("An error occurred: " + err))
        },
        newPasswordRequired: function (userAttributes, requiredAttributes) {
            cognitoUser.completeNewPasswordChallenge(p, userAttributes, this);
        },
    });

Seems like I missed the point mentioned in this post . Adding the below code works.

const WindowMock = require('window-mock');
global.window = {localStorage: WindowMock.localStorage};
global.navigator = () => null;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM