AWS Cognito 缺少函数

AWS Cognito missing functions

我正在尝试使用 AWS Cognito 和 AWS Cognito Identity 创建管理面板。我的问题是我的 CognitoIdentityServiceProvider 变量没有任何与组相关的功能,但有所有其他功能可用。

具体来说,我缺少 adminAddUserToGroup, adminListGroupsForUser, adminRemoveUserFromGroup, createGroup, deleteGroup, getGroup, listGroups, listUsersInGroup, and updateGroup

我正在这样设置我的变量。正在正确设置凭据。:

//Sign in, get creds, then do this.
admin = new AWSCognito.CognitoIdentityServiceProvider({
            credentials: AWSCognito.config.credentials
        });

当我 console.log(admin); 时,我得到了以下对象,我扩展了 __proto__ 以显示对象可用的功能。

b.constructor.b.constructor
_clientId:4
_originalConfig:(...)
get _originalConfig:()
config:constructor
endpoint:constructor
isGlobalEndpoint:false
__proto__: b.constructor.b.constructor
    addCustomAttributes: (a, c)
    adminConfirmSignUp:(a, c)
    adminDeleteUser:(a, c)
    adminDeleteUserAttributes:(a, c)
    adminDisableUser:(a, c)
    adminEnableUser:(a, c)
    adminForgetDevice: (a, c)
    adminGetDevice:(a, c)
    adminGetUser:(a, c)
    adminInitiateAuth:(a, c)
    adminListDevices :(a, c)
    adminResetUserPassword: (a, c)
    adminRespondToAuthChallenge:(a, c)
    adminSetUserSettings:(a, c)
    adminUpdateDeviceStatus:(a, c)
    adminUpdateUserAttributes:(a, c)
    adminUserGlobalSignOut:(a, c)
    api:d
    changePassword:(a, c)
    confirmDevice:(a, c)
    confirmForgotPassword:(a, c)
    confirmSignUp:(a, c)
    constructor:()
    createUserImportJob:(a, c)
    createUserPool:(a, c)
    createUserPoolClient:(a, c)
    deleteUser:(a, c)
    deleteUserAttributes:(a, c)
    deleteUserPool:(a, c)
    deleteUserPoolClient:(a, c)
    describeUserImportJob:(a, c)
    describeUserPool:(a, c)
    describeUserPoolClient:(a, c)
    forgetDevice:(a, c)
    forgotPassword:(a, c)
    getCSVHeader:(a, c)
    getDevice:(a, c)
    getUser:(a, c)
    getUserAttributeVerificationCode:(a, c)
    globalSignOut:(a, c)
    initiateAuth:(a, c)
    listDevices:(a, c)
    listUserImportJobs:(a, c)
    listUserPoolClients:(a, c)
    listUserPools:(a, c)
    listUsers:(a, c)
    resendConfirmationCode:(a, c)
    respondToAuthChallenge:(a, c)
    serviceIdentifier:"cognitoidentityserviceprovider"
    setUserSettings:(a, c)
    signUp:(a, c)
    startUserImportJob:(a, c)
    stopUserImportJob:(a, c)
    updateDeviceStatus:(a, c)
    updateUserAttributes:(a, c)
    updateUserPool:(a, c)
    updateUserPoolClient:(a, c)
    verifyUserAttribute:(a, c)
    __proto__: constructor

我包括了 aws-cognito-sdk.min.js, aws-cognito-identity-sdk.min.js 的最新版本,以及 aws-sdk 的默认构建。

我收到的错误是:

Uncaught Error: admin.adminListGroupsForUser is not a function
    at adminListGroupsForUser (aws-admin.js:121)
    at Object.<anonymous> (viewUsers.js:28)
    at Function.each (jquery.min.js:2)
    at n.fn.init.each (jquery.min.js:2)
    at buildUserTable (viewUsers.js:12)
    at constructor.<anonymous> (aws-admin.js:111)
    at constructor.<anonymous> (aws-cognito-sdk.min.js:4514)
    at constructor.callListeners (aws-cognito-sdk.min.js:4827)
    at constructor.emit (aws-cognito-sdk.min.js:4817)
    at constructor.emitEvent (aws-cognito-sdk.min.js:4607)
callListeners @ aws-cognito-sdk.min.js:4829
emit @ aws-cognito-sdk.min.js:4817
emitEvent @ aws-cognito-sdk.min.js:4607
a @ aws-cognito-sdk.min.js:4495
d.runTo @ aws-cognito-sdk.min.js:5499
(anonymous) @ aws-cognito-sdk.min.js:5507
(anonymous) @ aws-cognito-sdk.min.js:4501
(anonymous) @ aws-cognito-sdk.min.js:4608
callListeners @ aws-cognito-sdk.min.js:4833
emit @ aws-cognito-sdk.min.js:4817
emitEvent @ aws-cognito-sdk.min.js:4607
a @ aws-cognito-sdk.min.js:4495
d.runTo @ aws-cognito-sdk.min.js:5499
(anonymous) @ aws-cognito-sdk.min.js:5507
(anonymous) @ aws-cognito-sdk.min.js:4501
(anonymous) @ aws-cognito-sdk.min.js:4608
callListeners @ aws-cognito-sdk.min.js:4833
emit @ aws-cognito-sdk.min.js:4817
emitEvent @ aws-cognito-sdk.min.js:4607
a @ aws-cognito-sdk.min.js:4495
d.runTo @ aws-cognito-sdk.min.js:5499
(anonymous) @ aws-cognito-sdk.min.js:5507
(anonymous) @ aws-cognito-sdk.min.js:4501
(anonymous) @ aws-cognito-sdk.min.js:4608
callListeners @ aws-cognito-sdk.min.js:4833
emit @ aws-cognito-sdk.min.js:4817
emitEvent @ aws-cognito-sdk.min.js:4607
a @ aws-cognito-sdk.min.js:4495
d.runTo @ aws-cognito-sdk.min.js:5499
(anonymous) @ aws-cognito-sdk.min.js:5507
(anonymous) @ aws-cognito-sdk.min.js:4501
(anonymous) @ aws-cognito-sdk.min.js:4608
callListeners @ aws-cognito-sdk.min.js:4833
f @ aws-cognito-sdk.min.js:4821
(anonymous) @ aws-cognito-sdk.min.js:3191
d.emit @ aws-cognito-sdk.min.js:6769
finishRequest @ aws-cognito-sdk.min.js:3450
(anonymous) @ aws-cognito-sdk.min.js:3408

对于文字墙,我深表歉意,但我只是希望你们了解所有事实,以更好地帮助我理解为什么会出现此错误。我是否遗漏了一个包含,或者可能是其他什么?

谢谢。

函数 adminAddUserToGroup、adminListGroupsForUser、adminRemoveUserFromGroup、createGroup、deleteGroup、getGroup、listGroups、listUsersInGroup 和 updateGroup 是经过身份验证的操作,因此您需要 AWS 凭据才能访问它们,正如您实际注意到的那样。

它们通过主 AWS SDK 公开,如您所见,它们应该在 aws-sdk.

的最新版本中

https://github.com/aws/aws-sdk-js/blob/master/apis/cognito-idp-2016-04-18.min.json#L339

您需要做的就是导入主要的 AWS SDK,实例化相应的客户端,您应该可以访问它们。

var client = new AWS.CognitoIdentityServiceProvider({ apiVersion: '2016-04-19', region });