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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With