express-stormpath icon indicating copy to clipboard operation
express-stormpath copied to clipboard

stormpathApplication.getAccounts()

Open peebles opened this issue 8 years ago • 2 comments

I am using 4.0.0-rc4 and migrating a Stormpath app.

I am trying to find an account by email. My code

    var spapp    = app.get('stormpathApplication');
    spapp.getAccounts( { email: email }, function( err, collection ) {
      if ( err ) return cb( err );
      var accounts = [];
      collection.each( function( account, cb ) {
	accounts.push( account );
	cb();
      }, function( err ) {
	if ( err ) return cb( err );
       console.log( accounts );
    });

I have about 1000 accounts. The first problem is that getAccounts() is returning more than one account. The second problem is that it is returning only 50 accounts.

It seems like (1) the query is being ignored and (2) the collection iterator is not paging ... the default page size appears to be 50, and I only get the first page.

Am I doing something incorrectly?

peebles avatar Jul 01 '17 22:07 peebles

Passing in { limt: 50, offset: 100 } is also ignored. Limit seems to be honored, but no matter what offset is, I always get the first page.

peebles avatar Jul 01 '17 22:07 peebles

Hi @peebles , that method comes from the underlying Node SDK, which is not being 100% patched for Okta.

I would suggest trying the alpha version of our Okta Node SDK:

https://github.com/okta/okta-sdk-nodejs#list-all-org-users

Please note that this module is not yet on NPM, you you will need to use the Git URL in your package.json

The Okta pagination API is different, but does support limit parameter, which can be passed to client.listUsers({limit: 100})

https://developer.okta.com/docs/api/getting_started/design_principles.html#pagination

robertjd avatar Jul 05 '17 18:07 robertjd