Cognito UnknownError after turn on device registration

♀尐吖头ヾ 提交于 2020-01-03 08:28:26

问题


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);
        },
    });

回答1:


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;


来源:https://stackoverflow.com/questions/51985784/cognito-unknownerror-after-turn-on-device-registration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!