clerk / javascript

Official Javascript repository for Clerk authentication
https://clerk.com
MIT License
1.09k stars 240 forks source link

Javascript Backend SDK response is empty for `getInvitationList` #3650

Closed pavittarx closed 3 months ago

pavittarx commented 3 months ago

Preliminary Checks

Reproduction

https://replit.com/@PavittarSingh1/ClerkBackendAPI-1

Publishable key

pk_test_aGVscGluZy1qYWd1YXItODguY2xlcmsuYWNjb3VudHMuZGV2JA

Description

Steps to reproduce:

  1. Create an Organization
  2. Invite members from the UI Components.
  3. Try fetching the invitation list using getInvitationList Javascript Backend API.
  4. The list is empty

Expected behavior: The list should list at the very least the pending invitations.

Actual behavior: Empty list is being returned. However the list of pending invitations shows up in the UI component.

image image

Environment

System:
    OS: Linux 6.5 Ubuntu 20.04.2 LTS (Focal Fossa)
    CPU: (8) x64 AMD EPYC 7B13
    Memory: 13.97 GB / 62.79 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 18.12.1 - /nix/store/dj805sw07vvpbxx39c8g67x8qddg0ikw-nodejs-18.12.1/bin/node
    Yarn: 1.22.19 - /nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/bin/yarn
    npm: 8.19.2 - /nix/store/dj805sw07vvpbxx39c8g67x8qddg0ikw-nodejs-18.12.1/bin/npm
  npmPackages:
    @clerk/backend: ^1.2.4 => 1.2.4 
    @types/node: ^20.4.1 => 20.4.2 
    node-fetch: ^3.3.1 => 3.3.1 
    tsx: ^3.12.7 => 3.12.7
pavittarx commented 3 months ago

Same response with the API as well, image

dimkl commented 3 months ago

Hello @pavittarx and thank you for the report. It's seems that there is an issue with the response of the endpoint or our documentation / backend API ref. I will investigate it and provide feedback soon

dimkl commented 3 months ago

After investigating the cause of your issue is that you are using the endpoint to retrieve instance invitations from the backend API, but you want to retrieve organization invitation. This is not an issue in the API response, you need to use the current endpoint to retrieve the organization invitations.

curl -v -H "Authorization: Bearer {secretKey}" "https://api.clerk.com/v1/organizations/{orgID}/invitations?limit=10&offset=0"

or

// based on your screenshot
await clerk.organizations.getOrganizationInvitationList()

API ref: https://clerk.com/docs/reference/backend-api/tag/Organization-Invitations#operation/ListOrganizationInvitations cc: @pavittarx

dimkl commented 3 months ago

Closing this issue but feel free to open a new one if there is still an issue.