Expired Token Azure Powershell

Mohamed jihad bayali 1,136 Reputation points
2023-05-17T10:30:27.1433333+00:00

Hello Team,

I try to list certificates using powershell, i type:

connect-azaccount to login
az key vault certificate contact list --vault-name XXXXX

And i have the following error :
User's image

While executing Get-AzAccessToken, i see the token is expired, i tried, to sign out, sign in.... but i still have the error.

any idea how can i refresh the token?

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
1,448 questions
Microsoft Security Microsoft Entra Microsoft Entra ID
{count} votes

1 answer

Sort by: Most helpful
  1. JamesTran-MSFT 36,906 Reputation points Microsoft Employee Moderator
    2023-05-17T21:07:41.7266667+00:00

    @Mohamed jihad bayali

    Thank you for your post!

    Error: AADSTS700082

    ExpiredOrRevokedGrantInactiveToken - The refresh token has expired due to inactivity. The token was issued on {issueDate} and was inactive for {time}. Expected part of the token lifecycle - the user went an extended period of time without using the application, so the token was expired when the app attempted to refresh it.

    From your screenshot, it looks like the token you were issued was from January 31, 2023, since you already tried signing in/out but are still receiving this error within Azure PowerShell:

    1. Can you see if closing out of the PS window completely then signing back in using Connect-AzAccount helps resolve your issue? This should refresh the access token and allow you to list the certificates in your key vault.
    Connect-AzAccount
    
    # Get a new access token
    $accessToken = (Get-AzAccessToken -ResourceUrl "https://vault.azure.net").Token
    
    1. If this doesn't work, you can try to clear the token cache entirely and then refresh it using Clear-AzContext.
    # Clear the token cache
    Clear-AzContext -Scope Process
    
    # Connect to your Azure account again
    Connect-AzAccount
    
    # Get a new access token
    $accessToken = (Get-AzAccessToken -ResourceUrl "https://vault.azure.net").Token
    

    I hope this helps!

    If you have any other questions, please let me know. Thank you for your time and patience throughout this issue.


    If the information helped address your question, please Accept the answer. This will help us and also improve searchability for others in the community who might be researching similar information.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.