A little bit shorter this time….
If you retrieved to many AccessTokens geholt and are trying to make a REST Call, this might happen:
Invoke-RestMethod : {“error”:{“code”:”InvalidAuthenticationTokenTenant”,”message”:”The access token is from the wrong issuer
![](https://powershell24.de/wp-content/uploads/2020/05/2020-05-19_10h30_53-1024x219.png)
You’ve got too many tokens, and PowerShell doesn’t know which one to use. Which we can see like this:
$context = Get-AzContext
$context.TokenCache
![](https://powershell24.de/wp-content/uploads/2020/05/2020-05-19_10h34_56.png)
The easiest way to deal with this, is to simply clear the token cache:
(Get-AzContext).TokenCache.Clear() #Clear
(Get-AzContext).TokenCache #Verify
![](https://powershell24.de/wp-content/uploads/2020/05/2020-05-19_10h36_10.png)
The next REST Call will prompt us for the credential.
![](https://powershell24.de/wp-content/uploads/2020/05/2020-05-19_10h37_35-1024x331.png)
Finally, when checking the token cache once again, we can see that there is no more confusion.
![](https://powershell24.de/wp-content/uploads/2020/05/2020-05-19_10h39_54.png)