Skip to content

[Feature Request] Properly asynchronous client assertionsΒ #879

Closed

Description

MSAL client type

Confidential

Problem Statement

We use a client assertion as our client credential when building our confidential client application. This assertion comes from a file stored locally and gets refreshed every hour. At the moment the credential can only be created before the confidential client application is created, even when using the createFromCallback method meaning we need to create a whole new confidential client application everytime the token is refreshed.

Proposed solution

Ideally we would like to build one confidential client application that refreshes this client credential on every acquire token request.

I can see that we can create a client credential from a callback using createFromCallback but this still gets executed when the confidential client is created. Ideally this callback should be executed when the acquireToken method is called.

Alternatives

At the moment we need to either create a new confidential client for every request or somehow build a new confidential client every time the token is updated.

Activity

  1. added
    needs attentionAutomatically used when an issue is created through an issue template
    untriagedAutomatically used when an issue is created through an issue template
    on Nov 21, 2024
  2. added
    EnhancementA request or suggestion to improve some aspect of the library
    confidential-clientFor issues related to confidential client apps
    and removed
    needs attentionAutomatically used when an issue is created through an issue template
    untriagedAutomatically used when an issue is created through an issue template
    on Nov 21, 2024
  3. pdefreitas commented on May 2, 2025

    @pdefreitas

    +1 for this one. The .NET library provides a builder with WithClientAssertion(). The builder with plain string is obsolete. Node has also implemented async callbacks:
    AzureAD/microsoft-authentication-library-for-js#7014

  4. Avery-Dunn commented on Sep 12, 2025

    @Avery-Dunn
    Contributor

    Sorry for the slow response, however version 1.23.1 has been released containing a fix for this issue: https://github.com/AzureAD/microsoft-authentication-library-for-java/releases/tag/v1.23.1

    The bug you mentioned prevented the callback from being called more then once we configured at the app-level, but you may have still be able to set the assertion on each request when using ClientCredentialParameters.clientCredential()

    The changes in #988 should resolve this problem by fixing the bug and generally improving assertion behavior, so that the callback is called every time the assertion is needed. Let use know if you still have any issues after updating to 1.23.1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementA request or suggestion to improve some aspect of the libraryconfidential-clientFor issues related to confidential client apps

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions