刷新令牌上的aws-sdk错误

时间:2018-04-08 21:37:04

标签: amazon-web-services aws-sdk aws-sdk-js aws-sdk-nodejs

所以我写了这个小函数来刷新用户的标记:

function refreshToken (refreshToken) {
    const provider = new AWS.CognitoIdentityServiceProvider();
    const params = {
        AuthFlow: 'REFRESH_TOKEN_AUTH',
        ClientId: strapi.config.AWSClientAppId,
        UserPoolId: strapi.config.AWSUserPollId,
        AuthParameters: {
            REFRESH_TOKEN: refreshToken,
        }
    };

    return new Promise(function (resolve, reject) {
        provider.adminInitiateAuth(params, function (err, session) {
            if (err) {
                return reject(err);
            }
            resolve(session);
        });
    });
}

它可以运行一段时间,但是它会在一段时间后开始抛出错误。 我无法理解为什么会出现这种错误

{ TypeError: Key must be a buffer
at new Hmac (crypto.js:92:16)
at Object.Hmac (crypto.js:90:12)
at Object.hmac (/pipeline/source/node_modules/aws-sdk/lib/util.js:401:30)
at Object.getSigningKey (/pipeline/source/node_modules/aws-sdk/lib/signers/v4_credentials.js:59:8)
at V4.signature (/pipeline/source/node_modules/aws-sdk/lib/signers/v4.js:97:36)
at V4.authorization (/pipeline/source/node_modules/aws-sdk/lib/signers/v4.js:92:36)
at V4.addAuthorization (/pipeline/source/node_modules/aws-sdk/lib/signers/v4.js:34:12)
at /pipeline/source/node_modules/aws-sdk/lib/event_listeners.js:202:18
at finish (/pipeline/source/node_modules/aws-sdk/lib/config.js:313:7)
at /pipeline/source/node_modules/aws-sdk/lib/config.js:331:9
at /pipeline/source/node_modules/aws-sdk/lib/credentials.js:123:23
at Credentials.refresh (/pipeline/source/node_modules/aws-sdk/lib/credentials.js:194:5)
at Credentials.get (/pipeline/source/node_modules/aws-sdk/lib/credentials.js:121:12)
at getAsyncCredentials (/pipeline/source/node_modules/aws-sdk/lib/config.js:325:24)
at Config.getCredentials (/pipeline/source/node_modules/aws-sdk/lib/config.js:345:9)
at Request.SIGN (/pipeline/source/node_modules/aws-sdk/lib/event_listeners.js:179:22) retryDelay: 79.21510223637249 }

0 个答案:

没有答案