Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Token retrieval failed with an error In Azure Data Studio

Using the latest Azure Data Studio Version: 1.32.0

Attempting to access a database using Azure Active Directory MFA and am getting the error:

Token retrieval failed with an error. Open developer tools to view the error

How can I resolve?

Connection type: Microsoft SQL Server
Authentication type: Azure Active Directory - Universal with MFA support

The server, account, and database fields are all populated with their respective necessary information.

A browser window pops up asking for username/password, which I enter valid credentials for, followed by the authentication being confirmed in the browser that follows, accompanied by instructions to close the browser window. Azure Data Studio then has the error displayed as mentioned above.

like image 727
Mike Miller Avatar asked Nov 17 '25 16:11

Mike Miller


2 Answers

Problem seems to be with a cached token. try to delete the token from here C:\Users{UserNameHere}\AppData\Roaming\azuredatastudio\Azure Accounts and try to re authenticate.

like image 83
JayakrishnaGunnam-MT Avatar answered Nov 20 '25 05:11

JayakrishnaGunnam-MT


If you open the Command Palette - Ctrl + Shift + P on Windows - one of the options is Azure Accounts: Clear Azure Accounts Token Cache. After applying this you'll be prompted to reload ADS.

You should then be invited to refresh your account credentials when you attempt to create a connection. If you're not, run Azure: Refresh All Accounts from the Command Palette and try creating the connection again.

Explanation

As mentioned by @JayakrishnaGunnam-MT in their answer, the problem seems to be to do with cached tokens. Running the first command deletes azureTokenCache_azure_publicCloud and azureTokenCacheMsal-azure_publicCloud from C:\Users\{UserNameHere}\AppData\Roaming\azuredatastudio\Azure Accounts without you needing to do it manually.

like image 37
philipnye Avatar answered Nov 20 '25 05:11

philipnye