Skip to main content
import { useEffect, useState } from 'react';
import { useStytch } from '@stytch/react';

export const ConnectedAppsList = () => {
const stytch = useStytch();
const [apps, setApps] = useState([]);

useEffect(() => {
  const fetchApps = async () => {
    const { connected_apps } = await stytch.user.getConnectedApps();
    setApps(connected_apps);
  };

  fetchApps();
}, [stytch]);

return (
  <ul>
    {apps.map((app) => (
      <li key={app.connected_app_id}>{app.name}</li>
    ))}
  </ul>
);
};
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "connected_apps": [
    {
      "client_type": "first_party",
      "connected_app_id": "connected-app-test-aeadeabc-a3a3-4796-83d0-b757e3001000",
      "description": "A first party connected app",
      "logo_url": null,
      "name": "first-party-confidential-app",
      "scopes_granted": "openid profile email"
    }
  ]
}
user.getConnectedApps() wraps the User Get Connected Apps API endpoint. The user_id will be automatically inferred from the logged-in user’s session. This method retrieves a list of Connected Apps that the user has completed an authorization flow with successfully. If the user revokes a Connected App’s access (e.g. via the revokeConnectedApp method) then the Connected App will no longer be returned in this endpoint’s response.

Response

connected_apps
array[objects]
An array of Connected Apps with which the User has successfully completed an authorization flow.
request_id
string
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
status_code
number
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.