Skip to content

Add Configurable API Fetch Controls to Asgardeo SDK for Improved Performance#416

Merged
brionmario merged 6 commits intoasgardeo:mainfrom
dileepapeiris:feat-add-configs-to-disable-unnessary-api-calls
Mar 23, 2026
Merged

Add Configurable API Fetch Controls to Asgardeo SDK for Improved Performance#416
brionmario merged 6 commits intoasgardeo:mainfrom
dileepapeiris:feat-add-configs-to-disable-unnessary-api-calls

Conversation

@dileepapeiris
Copy link
Contributor

@dileepapeiris dileepapeiris commented Mar 19, 2026

Purpose

This PR introduces granular configuration options to control automatic API calls made by the Asgardeo JavaScript SDK during the authentication flow, addressing performance concerns and providing developers with fine-grained control over network requests.

Problem:
Currently, the SDK automatically makes multiple API calls after successful sign-in:

  • GET /scim2/Me - Fetches detailed user profile
  • GET /scim2/Schemas - Fetches user attribute schemas
  • GET /api/users/v1/me/organizations - Fetches user's associated organizations

These calls happen automatically even when applications don't need this data, impacting performance and increasing unnecessary network traffic.

Usage Example:

<AsgardeoProvider
  clientId="YOUR_CLIENT_ID"
  baseUrl="https://api.asgardeo.io/t/YOUR_ORG"
  preferences={{
    theme: {
      inheritFromBranding: false,  // Disable branding API
    },
    user: {
      fetchUserProfile: false,     // Disable SCIM2 calls
      fetchOrganizations: false,   // Disable organizations call
    },
  }}
>
  <App />
</AsgardeoProvider>

Related Issues

Related PRs

  • N/A

Verification

Tested using the samples/teamspace-react app. Here is the screen recording.

Screen.Recording.2026-03-20.at.01.31.29.mov

Checklist

  • Followed the CONTRIBUTING guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Add links if there are any)

Security checks

dileepapeiris and others added 6 commits March 20, 2026 01:01
Introduce a UserPreferences interface with fetchOrganizations and fetchUserProfile flags to control automatic fetching of a user's organizations and SCIM2 profile after sign-in (both default to true). Wire the new UserPreferences into the existing Preferences type as the optional user property. These options improve performance by allowing callers to disable automatic API calls and instead fetch organization/profile data manually when needed.
Introduce config flags to control server-side fetching of user/profile and organizations (config.preferences.user.fetchUserProfile and fetchOrganizations, defaulting to true). Split the previous monolithic try/catch into separate guarded flows so each fetch can fail independently and logs use logger.warn (replacing console.warn). Organizations fetching now skips myOrganizations when no sessionId and logs accordingly. This allows disabling expensive server calls and improves error isolation and logging.
Add checks for preferences.user.fetchUserProfile and preferences.user.fetchOrganizations (default: true) to conditionally fetch user, user profile, current organization, and my organizations. Related API calls are now wrapped in these conditionals while preserving existing try/catch error handling TODOs to avoid unnecessary network requests when disabled.
Add explanatory comments in samples/teamspace-react/src/main.tsx for the preferences prop passed to the Asgardeo provider. Comments document theme settings (including disabling automatic branding fetch), user settings (controlling automatic user profile and organization fetching), and note where to add i18n locale files. These are non-functional comment changes to improve developer guidance when customizing the client.
Create a changeset that bumps @asgardeo/javascript, @asgardeo/nextjs, and @asgardeo/react as minor releases. Introduces user preferences to control automatic API calls for fetching user profile and organizations, allowing clients to opt out of those automatic requests.
Added temporary note regarding user preferences configuration.
@asgardeo-github-bot
Copy link

🦋 Changeset detected

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants