Why is this returning all identities instead of on...
# talk-kratos
a
Why is this returning all identities instead of only the ones specified in idsFilter, is this a bug?
IdentityApi.listIdentities({ idsFilter: ['0dcbe686-ad1c-5885-b2e2-527d54ac60c1', 'b65256c5-13d1-1421-207s-3411dfg626d3'} })
Turns out after deeper googling I found this feature merge request: https://github.com/ory/kratos/pull/3598 Looks like the javascript SDK client and API documentation both has wrong info about it (unless ids_filter does something else) To bulk request identity ids the correct way is:
/admin/identities?ids=xxxx-xxxx-xxxx&ids=xxxx-xxxx-xxxx
and not
/admin/identities?ids_filter=xxxx-xxxx-xxxx&ids_filter=xxxx-xxxx-xxxx
Docs: https://www.ory.sh/docs/reference/api#tag/identity/operation/listIdentities
Though the merged feature does use ids_filter not ids, but expected query is still ids
IdsFilter:                    r.URL.Query()["ids"],
Edit aaand looks like closed fix merge request is the culprit: https://github.com/ory/kratos/pull/3676
s
Hey @ancient-salesclerk-58391! I am trying to achieve the behavior that you posted, use
listIdentities
and filter by
ids
.
Are you using the javascript SDK?
What version of
@ory/client
are you using?
a
Hey, yea I used npm
"@ory/client": "^1.5.1"
In short docs says it queries "ids_filters" but IdentityApi created query using "ids_filters" and not "ids". I ended up using custom axios query using the "ids" instead
https://github.com/ory/kratos/blob/549308db1f7dca42004631ed6156cae5f827b8fe/identity/handler.go#L190 This is where it expects ids not ids_filters (i havent looked deeper than that)
But yea main problem is that the docs says to use "ids_filters" but it's actually "ids"
s
Thanks for the info @ancient-salesclerk-58391!
I tried to implement it via
ids
but no luck.
Copy code
// Get all user's uid to query identities
    const ids = users?.docs?.map(({ uid }) => {
      return uid;
    });

    const usersOrgIdentities =
      await AuthClient.OrganisationIdentities.listIdentities({
        ids,
      });
I checked the typescript declaration file
Copy code
listIdentities: (perPage?: number, page?: number, pageSize?: number, pageToken?: string, consistency?: ListIdentitiesConsistencyEnum, idsFilter?: Array<string>, credentialsIdentifier?: string, previewCredentialsIdentifierSimilar?: string, options?: RawAxiosRequestConfig) => Promise<RequestArgs>;
Copy code
@param {Array<string>} [idsFilter] IdsFilter is list of ids used to filter identities. If this list is empty, then no filter will be applied.
Also tried
idsFilter
But filter not taking effect
a
Yeah I ended up writing custom axios call and not use the SDK `axios.get(
${oryAuth.ORY_NETWORK_PROJECT_API}/admin/identities?${queryParams}${ids}
, {...authEtc})`
s
Thanks for sharing @ancient-salesclerk-58391!
Yeah yeah hope they fix it soon.
a
Yea
Haven't had any other issues with the SDK endpoints, this is the only one I had issues with
s
Thanks for jumping in and sharing your solution @ancient-salesclerk-58391! Really appreciate it!
b
If you’re on the latest version, the SDK might not be able to handle these “array” query paremeters. Unfortunately, there is not much we can do about that, in the short term, as the SDKs are fully generated.
s
Gotcha @bland-eye-99092! Thanks for informing us. Appreciate it as it helped us to move forward.