Skip to content

Commit 555a4bc

Browse files
dineshreddy007digot007isra-fel
authored
Workaround for the token cache issue in Az.Accounts 2.1.0 (#13362)
* Workaround for the token cache issue in Az.Accounts 2.1.0 Using version 1.9.5 of Az.Accounts. * Update Az.StackHCI.psm1 Using AuthFactory.Authenticate instead of TokenCache * Updating the release notes. * revert the update to versions They'll be updated automatically during release process Co-authored-by: Dinesh Reddy Gottam <[email protected]> Co-authored-by: Yeming Liu <[email protected]>
1 parent 4889b1f commit 555a4bc

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/StackHCI/Az.StackHCI.psm1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ param(
197197
$graphTokenItemResource = $GraphEndpointResourceIdAzurePPE
198198
}
199199

200-
$graphTokenItem = [Microsoft.Azure.Commands.Common.Authentication.AzureSession]::Instance.TokenCache.ReadItems() | where { ($_.TenantId -eq "$TenantId") -and ($_.Resource -eq "$graphTokenItemResource")} | Sort-Object -Property ExpiresOn | Select-Object -Last 1
200+
$authFactory = [Microsoft.Azure.Commands.Common.Authentication.AzureSession]::Instance.AuthenticationFactory
201+
$azContext = Get-AzContext
202+
$graphTokenItem = $authFactory.Authenticate($azContext.Account, $azContext.Environment, $azContext.Tenant.Id, $null, [Microsoft.Azure.Commands.Common.Authentication.ShowDialog]::Never, $null, $graphTokenItemResource)
201203
return $graphTokenItem.AccessToken
202204
}
203205

src/StackHCI/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Workaround for the token cache issue in Az.Accounts 2.1.0. Using AuthenticationFactory.
2122

2223
## Version 0.3.0
2324
* Get the App Roles assigned correctly in case of Stack HCI registration using WAC token.

0 commit comments

Comments
 (0)