我正在尝试使用AWS Cognito和AWS Cognito Identity创建管理面板。我的问题是我的CognitoIdentityServiceProvider变量没有任何与组相关的功能,但是所有其他功能都可用。
具体而言,我遗漏了adminAddUserToGroup,adminListGroupsForUser,adminRemoveUserFromGroup,createGroup,deleteGroup,getGroup,{{3} },listGroups和listUsersInGroup。
我正在设置我的变量。凭证设置正确。:
//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
我包含了updateGroup,aws-cognito-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
我很抱歉文字的墙,但我只是想让所有的事实更好地帮助我理解为什么我会收到这个错误。我错过了一个包含,还是可能还有别的东西?
谢谢。
答案 0 :(得分:5)
函数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 });