Skip to content

Reducing the cost of building a ClientApplication #549

@aukeschaap

Description

@aukeschaap

Context

I am building a web app that logs a user in and that then accesses a protected web api. I have found that building a ConfidentialClientApplication is costly. Due to tenant discovery, atleast one get request is sent. This means that acquiring a token from the cache incurs this same cost.

Ideally you would build the ClientApplication once, and reuse it. There is, however, some (standard) overhead involved:

  • The token cache is unique for each session, and hence the CCA.
  • The application might be threaded (in my case it is).

The documentation offers no information on how to address these scenarios, especially now that the move to identity has been initiated. The only relevant information I found was: a comment in the code suggesting the CCA should be "long-lived", a mention in the new identity documentation that the instance is expected to be long-lived.

Questions

I hope you could clarify the following things in the documentation, for me and future developers:

  • How long is "long-lived"? A minute, hour, day, or even longer?
  • How to create a long-lived, session unique CCA? Specifically, how new requests can use the same CCA.
  • What issues arise when using a threaded server in combination with a TokenCache
  • How (or if) these threading issues can be avoided

I have done a lot of digging myself, and can identify some threading issues, but it would be nice to include them in the documentation.

Lastly, there is also the question of async support. I see that this issue tracks the progress already, so I have excluded that from this discussion.

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