Steps to reproduce:
ConfidentialClientApplication confidentialClientApplication = getManagedIdentityConfidentialClient();
TokenRequestContext tokenRequestContext = new TokenRequestContext().addScopes("https://vault.azure.net/.default");
ClientCredentialParameters.ClientCredentialParametersBuilder builder =
ClientCredentialParameters.builder(new HashSet<>(tokenRequestContext.getScopes()))
.tenant("organizations");
IAuthenticationResult authenticationResult = confidentialClientApplication.acquireToken(builder.build()).get();
System.out.println(authenticationResult.metadata().refreshOn());
```java
static ConfidentialClientApplication getManagedIdentityConfidentialClient() {
String authorityUrl = AzureAuthorityHosts.AZURE_PUBLIC_CLOUD + "organizations";
// Temporarily pass in Dummy Client secret and Client ID. until MSal removes its requirements.
IClientCredential credential = ClientCredentialFactory
.createFromSecret("dummy-secret");
ConfidentialClientApplication.Builder applicationBuilder =
ConfidentialClientApplication.builder( "SYSTEM-ASSIGNED-MANAGED-IDENTITY", credential);
applicationBuilder
.instanceDiscovery(false)
.validateAuthority(false)
.logPii(true);
try {
applicationBuilder = applicationBuilder.authority(authorityUrl);
} catch (MalformedURLException e) {
throw (new IllegalStateException(e));
}
applicationBuilder.appTokenProvider(appTokenProviderParameters -> {
System.out.println("Invoking Callback");
TokenRequestContext trc = new TokenRequestContext()
.setScopes(new ArrayList<>(appTokenProviderParameters.scopes))
.setClaims(appTokenProviderParameters.claims)
.setTenantId(appTokenProviderParameters.tenantId);
Random random = new Random();
Mono<AccessToken> accessTokenAsync = Mono
.just(new AccessToken("dummy-token" + random.nextInt(1000), OffsetDateTime.now(ZoneOffset.UTC).plusMinutes(10), OffsetDateTime.now(ZoneOffset.UTC).plusMinutes(2)));
return accessTokenAsync.map(accessToken -> {
TokenProviderResult result = new TokenProviderResult();
result.setAccessToken(accessToken.getToken());
result.setTenantId(trc.getTenantId());
result.setExpiresInSeconds(accessToken.getExpiresAt().toEpochSecond());
if (accessToken.getRefreshAt() != null) {
result.setRefreshInSeconds(accessToken.getRefreshAt().toEpochSecond());
}
return result;
}).toFuture();
});
return applicationBuilder.build();
}
### Expected behavior
The refreshOn info should flow to AuthenticationResult -> Metadata -> refreshOn API.
### Identity provider
Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)
### Regression
_No response_
### Solution and workarounds
_No response_
Library version used
1.16.0
Java version
17
Scenario
ConfidentialClient - service to service (AcquireTokenForClient)
Is this a new or an existing app?
The app is in production, and I have upgraded to a new version of MSAL
Issue description and reproduction steps
The refreshOn information isn't wired in AuthenticationResult -> Metadata -> RefreshOn, it comes back as null.
It is missing the wiring here
This issue is a blocker for Cosmos team.
Relevant code snippets