The error occurs while running the powershell script provided.
Exception calling "AcquireAccessToken" with "1" argument(s): "multiple_matching_tokens_detected: The cache contains multiple tokens satisfying the requirements. Call AcquireToken again
providing more arguments (e.g. UserId)"
At line:4 char:1
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@AakashMasand Thanks for the feedback! I have assigned the issue to the content author to evaluate and update as appropriate.
@AakashMasand Sorry for the delay, I've been out-of-office. That page has a lot of PowerShell examples. Which one specifically are you running that gave you that error message?
@MicrosoftDocs/azure-cxp-triage #in-progress
@AakashMasand I missed that you included the line you had issues with (starting with $token) in your comment. I just tried that entire snippet again in Cloud Shell and it works fine. I deleted my storage and started fresh to make sure it wasn't profile or a configuration and it still works fine.
Are you logging into both Commercial and National Clouds before trying this or multiple accounts? The recommendation for this error is to close any windows or programs (Visual Studio, VSCode, cmd, PowerShell, etc.) that may have tokens connected to Azure and authenticate a single account from scratch. Sometimes you have to flush a cache to do so, as well.
Since the doc is correct, if you continue to have this issue, please open a ticket with Azure Support. Thanks!
@MicrosoftDocs/azure-cxp-triage #please-close
@MicrosoftDocs/azure-cxp-triage Please remove the 'doc-bug' label and update with 'product-question. Thanks!
Hi I tried running the Powershell snippet again today to do the check and have encountered the same error. I did not check it then, however, on re running it today I have faced the exact same issue.
$azContext = Get-AzContext
$azProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile
$profileClient = New-Object -TypeName Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient -ArgumentList ($azProfile)
$token = $profileClient.AcquireAccessToken($azContext.Subscription.TenantId)
$authHeader = @{
'Content-Type'='application/json'
'Authorization'='Bearer ' + $token.AccessToken
}
$restUri = "https://management.azure.com/subscriptions/
$response = Invoke-RestMethod -Uri $restUri -Method POST -Headers $authHeader
$response
@AakashMasand I'd recommend opening a support ticket as I'm unable to replicate the issue you are having and it may be related to other variables. Thanks!
@AakashMasand Try running Clear-AzContext then connecting to Azure again. If you have more than one Context in cache it will throw this error.
Most helpful comment
@AakashMasand Try running Clear-AzContext then connecting to Azure again. If you have more than one Context in cache it will throw this error.