Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Cognito missing functions

I am attempting to create an admin panel using AWS Cognito and AWS Cognito Identity. My problem is that my CognitoIdentityServiceProvider variable does not have any functions related to groups, but has all of the other functions available.

To be specific, I am missing adminAddUserToGroup, adminListGroupsForUser, adminRemoveUserFromGroup, createGroup, deleteGroup, getGroup, listGroups, listUsersInGroup, and updateGroup.

I am setting my variable like so. The credentials are being set correctly.:

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

When I console.log(admin);, I am provided with the below Object, I have expanded the __proto__ to show what functions are available to the Object.

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

I am including the letest versions of aws-cognito-sdk.min.js, aws-cognito-identity-sdk.min.js, and the default build for the aws-sdk.

The error I receive is:

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

I'm sorry for the wall of text, but I just want ya'll to have all of the facts to better help me understand why I am getting this error. Am I missing an include, or possibly something else?

Thank you.

like image 640
Hypnic Jerk Avatar asked Jan 20 '17 17:01

Hypnic Jerk


1 Answers

The functions adminAddUserToGroup, adminListGroupsForUser, adminRemoveUserFromGroup, createGroup, deleteGroup, getGroup, listGroups, listUsersInGroup, and updateGroup are authenticated operations so you need AWS credentials to access them as you actually noted.

They are exposed through the main AWS SDK and as you can see they should be in the latest version of the aws-sdk.

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

All you need to do is import the main AWS SDK, instantiate the corresponding client and you should have access to them.

var client = new AWS.CognitoIdentityServiceProvider({ apiVersion: '2016-04-19', region });
like image 196
Ionut Trestian Avatar answered Oct 02 '22 18:10

Ionut Trestian