Reputation: 213
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.
Upvotes: 20
Views: 30242
Reputation: 31721
You have cached stale credentials.
Select the credentials in the Accounts
section, delete them and then add fresh credentials.
Upvotes: 17
Reputation: 2026
For MacOS user, please find /Users/{your_username}/Library/Application Support/azuredatastudio/Azure Account
and remove it.
There is sometimes bug even download latest version but can't work, so I would recommend remove azuredatastudio
for sure.
Upvotes: 0
Reputation: 695
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.
Upvotes: 18
Reputation: 1876
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.
Upvotes: 58