gpt4 book ai didi

javascript - AWS Cognito 缺少函数

转载 作者:数据小太阳 更新时间:2023-10-29 04:43:34 26 4
gpt4 key购买 nike

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

具体来说,我缺少adminAddUserToGroup , adminListGroupsForUser , adminRemoveUserFromGroup , createGroup , deleteGroup , getGroup , listGroups , listUsersInGroup , 和 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 });

关于javascript - AWS Cognito 缺少函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41768912/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com