Skip to content

bug: Authenticated API Calls Fail for Secondary AsgardeoProvider Instances (Multi-Provider Support) #335

@kavindadimuthu

Description

@kavindadimuthu

Description

In a scenario where multiple AsgardeoProvider components are instantiated within a single application (to support multiple concurrent sessions/organizations), authenticated API calls (httpRequest) only succeed for the first initialized provider.

Attempts to make authenticated requests via the useAuthContext() hook from subsequent (second, third, etc.) AsgardeoProvider instances fail. It appears that the SDK's internal state or the HTTP client instance might be binding to the first provider's configuration and is not correctly switching context for subsequent providers.

Expected Behavior

The httpRequest method should function correctly for all AsgardeoProvider instances independently. The SDK should isolate the HTTP client, token storage, and configuration for each provider instance, allowing concurrent authenticated calls.

Actual Behavior

  • Provider A (First Instance): API calls function as expected.
  • Provider B (Subsequent Instances): API calls fail.

Steps to Reproduce

  1. Initialize a React application.
  2. Set up two distinct AsgardeoProvider instances (Provider A and Provider B) with different configurations/scopes.
  3. Authenticate successfully using Provider A.
  4. Authenticate successfully using Provider B.
  5. Execute an authenticated API call using httpRequest from Provider A. -> Result: SUCCESS.
  6. Execute an authenticated API call using httpRequest from Provider B. -> Result: FAIL.

Please select the area the issue is related to

@asgardeo/javascript, @asgardeo/browser, @asgardeo/react

Version

N/A

Environment Details (with versions)

No response

Reporter Checklist

  • I have searched the existing issues and this is not a duplicate.
  • I have provided all the necessary information.
  • I have tested the issue on the latest version of the package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions