Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stuck in loop: "Error: Failed to get credential for account <email>. Please refresh the account" #8829

Closed
fabich opened this issue Jan 7, 2020 · 30 comments

Comments

@fabich
Copy link

fabich commented Jan 7, 2020

Issue Type: Bug

Azure account shows error message:
Error: Failed to get credential for account . Please refresh the account
image

After refreshing account (browser opens, copying code, get confirmation) I can try again
Now I get an error in Linked Accounts pane:
You need to refresh the credentials for this account.
image

Can try over and over again.
Reinstalled application - no change

Azure Data Studio version: azuredatastudio 1.14.1 (f9b968c, 2019-12-24T02:42:26.303Z)
OS version: Windows_NT x64 10.0.18363

System Info
Item Value
CPUs Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz (12 x 2208)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: enabled
rasterization: enabled
skia_renderer: disabled_off
surface_control: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.74GB (7.88GB free)
Process Argv
Screen Reader no
VM 0%
Extensions: none
@adsbot
Copy link

adsbot bot commented Jan 7, 2020

@fabich
Copy link
Author

fabich commented Jan 7, 2020

Readding account as suggested in #8766 did not resolve issue

@fabich
Copy link
Author

fabich commented Jan 7, 2020

Same problem with insider build

Azure Data Studio version: azuredatastudio-insiders 1.15.0-insider (362af3c, 2020-01-06T06:03:56.006Z)
OS version: Windows_NT x64 10.0.18363

System Info
Item Value
CPUs Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz (12 x 2208)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: enabled
rasterization: enabled
skia_renderer: disabled_off
surface_control: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.74GB (8.45GB free)
Process Argv
Screen Reader no
VM 0%
Extensions: none

@aaomidi aaomidi self-assigned this Jan 8, 2020
@aaomidi aaomidi added this to the February 2020 milestone Jan 8, 2020
@aaomidi
Copy link
Contributor

aaomidi commented Jan 8, 2020

Can you try #7619 (comment)

@fabich
Copy link
Author

fabich commented Jan 8, 2020

Can you try #7619 (comment)

not sure if I'm missing something but after clicking on Add an account a browser with the URL https://localhost:22209/signin?nonce=xxxxxx opens?

@aaomidi
Copy link
Contributor

aaomidi commented Jan 8, 2020

That's supposed to redirect to the microsoft authentication site. Is it just getting stuck on that page?

@fabich
Copy link
Author

fabich commented Jan 8, 2020

That's supposed to redirect to the microsoft authentication site. Is it just getting stuck on that page?

Yes, nothing else happening:
image

@aaomidi
Copy link
Contributor

aaomidi commented Jan 8, 2020

Why is it trying to open that page in https? That seems odd, do you have https everywhere configured? Or something to force https for localhost?

@fabich
Copy link
Author

fabich commented Jan 9, 2020

I got the new auth process to work.
After successful sign in I'm stuck in the same loop

@fabich
Copy link
Author

fabich commented Jan 13, 2020

@aaomidi do you have another idea?

@aaomidi
Copy link
Contributor

aaomidi commented Jan 13, 2020

Do you have any logs you can share from the developer console?

@fabich
Copy link
Author

fabich commented Jan 14, 2020

please have a look below:

console.<computed> @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [createInstance] First service dependency of e at position 3 conflicts with 0 static arguments
console.<computed> @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] Initialized Azure account extension storage.
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] logFile for MicrosoftSqlToolsServiceLayer.exe is c:\Users\{User}\AppData\Roaming\azuredatastudio\logs\20200114T072443\exthost1\Microsoft.mssql\sqltools.log
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] This process (ui Extenstion Host) is pid: 20612
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] Old log files deletion report: {}
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] logFile for MicrosoftSqlToolsCredentials.exe is c:\Users\{User}\AppData\Roaming\azuredatastudio\logs\20200114T072443\exthost1\Microsoft.mssql\credentialstore.log
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] This process (ui Extenstion Host) is pid: 20612
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] Old log files deletion report: {}
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] logFile for SqlToolsResourceProviderService.exe is c:\Users\{User}\AppData\Roaming\azuredatastudio\logs\20200114T072443\exthost1\Microsoft.mssql\resourceprovider.log
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] This process (ui Extenstion Host) is pid: 20612
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] Old log files deletion report: {}
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host]% null true
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host]% null true
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host]% null true
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] Refreshing account [object Object] failed - Error: Entry not found in cache.
console.<computed> @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] (node:20612) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
console.<computed> @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280
t.log @ workbench.desktop.main.js:385
$logExtensionHostMessage @ workbench.desktop.main.js:4295
_doInvokeHandler @ workbench.desktop.main.js:4301
_invokeHandler @ workbench.desktop.main.js:4301
_receiveRequest @ workbench.desktop.main.js:4300
_receiveOneMessage @ workbench.desktop.main.js:4299
(anonymous) @ workbench.desktop.main.js:4297
fire @ workbench.desktop.main.js:196
fire @ workbench.desktop.main.js:527
_receiveMessage @ workbench.desktop.main.js:532
(anonymous) @ workbench.desktop.main.js:529
fire @ workbench.desktop.main.js:196
acceptChunk @ workbench.desktop.main.js:525
(anonymous) @ workbench.desktop.main.js:524
t @ workbench.desktop.main.js:535
ZoneDelegate.invokeTask @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:421
Zone.runTask @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:188
ZoneTask.invokeTask @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:496
ZoneTask.invoke @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:485
emit @ events.js:200
addChunk @ _stream_readable.js:294
readableAddChunk @ _stream_readable.js:275
Readable.push @ _stream_readable.js:210
onStreamRead @ internal/stream_base_commons.js:166
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] (node:20612) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
console.<computed> @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280
t.log @ workbench.desktop.main.js:385
$logExtensionHostMessage @ workbench.desktop.main.js:4295
_doInvokeHandler @ workbench.desktop.main.js:4301
_invokeHandler @ workbench.desktop.main.js:4301
_receiveRequest @ workbench.desktop.main.js:4300
_receiveOneMessage @ workbench.desktop.main.js:4299
(anonymous) @ workbench.desktop.main.js:4297
fire @ workbench.desktop.main.js:196
fire @ workbench.desktop.main.js:527
_receiveMessage @ workbench.desktop.main.js:532
(anonymous) @ workbench.desktop.main.js:529
fire @ workbench.desktop.main.js:196
acceptChunk @ workbench.desktop.main.js:525
(anonymous) @ workbench.desktop.main.js:524
t @ workbench.desktop.main.js:535
ZoneDelegate.invokeTask @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:421
Zone.runTask @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:188
ZoneTask.invokeTask @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:496
ZoneTask.invoke @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:485
emit @ events.js:200
addChunk @ _stream_readable.js:294
readableAddChunk @ _stream_readable.js:275
Readable.push @ _stream_readable.js:210
onStreamRead @ internal/stream_base_commons.js:166

@aaomidi aaomidi modified the milestones: February 2020, March 2020 Jan 29, 2020
@aaomidi
Copy link
Contributor

aaomidi commented Jan 29, 2020

I'm going to move this issue to march since I have been unable to repro this locally.

@bergeron
Copy link
Contributor

bergeron commented Feb 7, 2020

This is also happening to me. I add my Azure account, and the browser logs me in successfully. The account is added:

image

image

image

But when I try to expand my list of subscriptions, I'm told to refresh the account:

image

image

I do this, and the browser logs me in successfully. But the message about refreshing the account remains. I tried deleting/re-adding the Azure account and uninstalling/reinstalling Azure Data Studio, but the error remains. I can only reproduce this on Ubuntu 16.04 Linux. I'm able to add my Azure account using the same Azure Data Studio build/commit on Windows. Let me know if there is any other information I can share.

Version: 1.15.0-insider
Commit: 343daf5
Date: 2020-02-06T05:32:20.142Z
VS Code: 1.42.0
Electron: 6.1.6
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Linux x64 4.15.0-76-generic

@aaomidi
Copy link
Contributor

aaomidi commented Feb 7, 2020

I will test this ASAP on Linux. There shouldn't be a big difference in how it works, so that's definitely weird.

Are there any errors on the developer log? Help -> Toggle Developer Tools?

@bergeron
Copy link
Contributor

bergeron commented Feb 7, 2020

No errors in this log. This is the only entry after going through all the steps:
image

@aaomidi
Copy link
Contributor

aaomidi commented Feb 7, 2020

Interesting, thank you! I'll check on it asap.

@bergeron
Copy link
Contributor

I attached a debugger to the latest commit eeae87e and see the following error:

message:"Entry not found in cache."
stack:"Error: Entry not found in cache.
	at Logger.createError (/home/brian/azuredatastudio/extensions/azurecore/node_modules/adal-node/lib/log.js:216:13)
	at TokenRequest.<anonymous> (/home/brian/azuredatastudio/extensions/azurecore/node_modules/adal-node/lib/token-request.js:526:40)
	at /home/brian/azuredatastudio/extensions/azurecore/node_modules/adal-node/lib/token-request.js:148:20
	at /home/brian/azuredatastudio/extensions/azurecore/node_modules/adal-node/lib/cache-driver.js:366:7
	at /home/brian/azuredatastudio/extensions/azurecore/node_modules/adal-node/lib/cache-driver.js:301:7
	at Request._callback (/home/brian/azuredatastudio/extensions/azurecore/node_modules/adal-node/lib/util.js:130:7)
	at Request.callback (/home/brian/azuredatastudio/extensions/azurecore/node_modules/request/request.js:185:22)
	at Request.emit (events.js:203:13)
	at Request.<anonymous> (/home/brian/azuredatastudio/extensions/azurecore/node_modules/request/request.js:1161:10)
	at Request.emit (events.js:203:13)
	at IncomingMessage.<ano...

It's thrown by this line with the breakpoint:

image

@aaomidi
Copy link
Contributor

aaomidi commented Feb 24, 2020

Hi, unfortunately this is an issue with the adal-node library :( We're in the process of updating our authentication scheme #9141.

In the meantime you can enable device login #9147 (comment)

@aaomidi aaomidi modified the milestones: March 2020, April 2020 Mar 9, 2020
@aaomidi
Copy link
Contributor

aaomidi commented Mar 9, 2020

We've hit some delays with the update to MSAL, hopefully April is an achievable goal.

@aaomidi
Copy link
Contributor

aaomidi commented Apr 2, 2020

This should be fixed in the latest insiders.

@aaomidi aaomidi closed this as completed Apr 2, 2020
@kevin-david
Copy link

kevin-david commented Jul 6, 2020

I'm still seeing issues that seem related to this - no matter how I try to refresh/remove/readd my account, I consistently get "Failed to get Azure account token for connection" when I try to log in. This is with the latest insiders build:

Version Info
Version: 1.20.0-insider
Commit: 2d989e1180f342d684a4e26f76b941843b7fc261
Date: 2020-07-03T05:33:54.074Z
VS Code: 1.46.0
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 19.5.0

It looks like I'm hitting the condition created by #9921:

[Extension Host] Could not refresh access token for {"id":"a78ab2cf-2bda-4133-a498-7a09555496bd","displayName":"<tenant>","userId":"kevin@<tenant_domain>","tenantCategory":"Home"} - silently removing the tenant from the user's account. (at d.getSecurityToken (/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/extensions/azurecore/dist/extension.js:16:126481))
/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/node_modules.asar/zone.js/dist/zone-node.js:2280  INFO No security tokens found for account
/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/node_modules.asar/zone.js/dist/zone-node.js:2280   ERR Error: Failed to get Azure account token for connection
    at e.connectWithOptions (connectionManagementService.ts:474) [<root>]
    at processTicksAndRejections (internal/process/task_queues.js:85) [<root>]
    at async k.handleDefaultOnConnect (connectionDialogService.ts:254) [<root>]

I've verified that I can actually perform DB operations in the portal, and this has worked in the past.

On application launch, I get the error: Error when adding your account to the cache. from the "Azure (Core) (Extension)"

Possibly interesting, the AAD tenant backing my subscription is set up with G suite as the IdP for AAD as described here: https://github.com/IAmFrench/GSuite-as-identity-Provider-IdP-for-Office-365-or-Azure-Active-Directory

Let me know if I should open a new issue for this or how I can help debug.

@aaomidi
Copy link
Contributor

aaomidi commented Jul 6, 2020

I'm guessing that GSuite being the IdP is probably part of the issue. I'm making a new PR #11208 to give us some more context on what the error was.

Once it's merged, tomorrows insider build should have the latest changes. If this is urgent, you can build from source and test that way as well. (https://github.com/microsoft/azuredatastudio/wiki/Developer-Getting-Started-Guide)

@kevin-david
Copy link

Tested out the new insider build today. Here's my console output from today's attempt:

[Extension Host] Error: Error when adding your account to the cache.	at d.setCachedToken (/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/extensions/azurecore/dist/extension.js:16:131174)	at d.refreshAccessToken (/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/extensions/azurecore/dist/extension.js:16:130991)	at processTicksAndRejections (internal/process/task_queues.js:85:5)	at async d.refreshAccess (/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/extensions/azurecore/dist/extension.js:16:125411)	at async u._initialize (/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/extensions/azurecore/dist/extension.js:166:32430) (at d.refreshAccess (/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/extensions/azurecore/dist/extension.js:16:125700))
/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/node_modules.asar/zone.js/dist/zone-node.js:2280 [Extension Host] Could not refresh access token for {"id":"a78ab2cf-2bda-4133-a498-7a09555496bd","displayName":"<tenant>","userId":"kevin@<tenant_domain>.org","tenantCategory":"Home"} - silently removing the tenant from the user's account. (at d.getSecurityToken (/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/extensions/azurecore/dist/extension.js:16:126491))
/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/node_modules.asar/zone.js/dist/zone-node.js:2280 [Extension Host] Actual error: "Error when adding your account to the cache." (at d.getSecurityToken (/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/extensions/azurecore/dist/extension.js:16:126618))

@aaomidi
Copy link
Contributor

aaomidi commented Jul 8, 2020

@kevin-david Settings -> Azure -> "No System Keychain" - is it checked or not?

You might want to disable the system keychain and try it again.

You may also have some interesting information on startup of the application.

@kevin-david
Copy link

@aaomidi sorry for the delay getting back to you. I installed the latest insiders build today and this appears to be fixed?

Working Version Info
Version: 1.21.0-insider
Commit: eccf3cf5fe8f60d04d70096bc94c654cab60d81a
Date: 2020-07-24T09:28:31.172Z
VS Code: 1.48.0
Electron: 9.1.0
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Darwin x64 19.6.0

It doesn't work on the latest non-insiders build, as far as I can tell. Before I updated, I got an error I hadn't seen before: Error running command azure.resource.selectsubscriptions: Cannot set property 'isStale' of undefined. This is likely caused by the extension that contributes azure.resource.selectsubscriptions.

Hope this helps, and glad it seems to be working again!

@aaomidi
Copy link
Contributor

aaomidi commented Jul 25, 2020

Yep the fix is only in insiders right now. I'm glad to see it's working now!

@aaomidi
Copy link
Contributor

aaomidi commented Jul 25, 2020

I'll be closing this issue now - please test with the latest insiders and let me know if any issues pop up with this. If the issue is unrelated to this one please open a new one!

@aaomidi aaomidi closed this as completed Jul 25, 2020
@IanKemp
Copy link

IanKemp commented Jul 31, 2020

How do I get an insiders build?

@adsbot adsbot bot locked and limited conversation to collaborators Sep 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants