aws / aws-toolkit-vscode

Amazon Q, CodeCatalyst, Local Lambda debug, SAM/CFN syntax, ECS Terminal, AWS resources
https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.amazon-q-vscode
Apache License 2.0
1.47k stars 408 forks source link

Can not authenticate connection after visiting startUrl externally #3404

Closed anyfactor closed 1 year ago

anyfactor commented 1 year ago

Problem

I can not authenticate the connection to AWS' endpoints. Followed the steps described here: https://aws.amazon.com/codewhisperer/resources/#Getting_started/

Steps to reproduce the issue

  1. Followed the steps described in https://aws.amazon.com/codewhisperer/resources/#Getting_started/
  2. Connected and validated the code produced by VSCode from the browser and verified my account.
  3. But the connection to VS Code editor was not successful

Error:

2023-05-01 00:18:01 [ERROR]: log level: info
2023-05-01 00:18:01 [INFO]: endpoints: retrieving AWS endpoints data
2023-05-01 00:18:01 [INFO]: OS: Windows_NT x64 10.0.19045
2023-05-01 00:18:01 [INFO]: Visual Studio Code extension host:  1.77.3
2023-05-01 00:18:01 [INFO]: AWS Toolkit:  1.71.0
2023-05-01 00:18:01 [INFO]: node: 16.14.2
2023-05-01 00:18:01 [INFO]: electron: 19.1.11
2023-05-01 00:18:01 [WARN]: AwsContext: no default region in credentials profile, falling back to us-east-1: 
2023-05-01 00:18:17 [ERROR]: aws.codeWhisperer.reconnect: Error: Unable to authenticate connection
     -> TypeError: Cannot destructure property 'id' of 'undefined' as it is undefined.
2023-05-01 00:23:03 [INFO]: telemetry: sent batch (size=18)
2023-05-01 00:28:04 [INFO]: telemetry: sent batch (size=1)
2023-05-01 01:19:38 [ERROR]: aws.codeWhisperer.reconnect: Error: Unable to authenticate connection
     -> TypeError: Cannot destructure property 'id' of 'undefined' as it is undefined.
2023-05-01 01:19:38 [ERROR]: aws.codeWhisperer.reconnect: Error: Unable to authenticate connection
     -> TypeError: Cannot destructure property 'id' of 'undefined' as it is undefined.

image

Expected behavior

The expected behavior is to have a successful and operational connection to the CodeWhisperer.

System details (run the AWS: About Toolkit command)

justinmk3 commented 1 year ago

Try clicking on the "AWS" icon in the vscode sidebar. If there is still an issue, try Sign Out in the context menu and then login again.

image

Duplicate: https://github.com/aws/aws-toolkit-vscode/issues/3403

chyld commented 1 year ago

I have VS Code installed on a Mac, but my code and therefore the extension is running in a Linux Docker container. I have a Builder ID, but I get this error message:

2023-05-01 10:53:07 [ERROR]: log level: info
2023-05-01 10:53:07 [INFO]: endpoints: retrieving AWS endpoints data
2023-05-01 10:53:07 [INFO]: OS: Linux x64 5.15.49-linuxkit
2023-05-01 10:53:07 [INFO]: Visual Studio Code extension host:  1.77.3
2023-05-01 10:53:07 [INFO]: AWS Toolkit:  1.71.0
2023-05-01 10:53:07 [INFO]: node: 16.14.2
2023-05-01 10:53:07 [WARN]: AwsContext: no default region in credentials profile, falling back to us-east-1: 
2023-05-01 10:53:26 [ERROR]: aws.codeWhisperer.reconnect: Error: Unable to authenticate connection
     -> TypeError: Cannot destructure property 'id' of 'undefined' as it is undefined.

And these are the only files under my ~/.aws/sso/cache directory. There are no other files under ~/.aws.

.rw-r--r-- 2.6k chyld  1 May 10:52 1c25b91499ed34507774bd1856f666a5cb2682ec.json
.rw-r--r-- 1.9k chyld  1 May 10:50 aws-toolkit-vscode-client-id-us-east-1-c6cd4d7a1af2d3b1a3ecd56308062b11f46a5be47a1cc51bb1615505222fde13.json

Any ideas on a fix? Is it because I'm using it in a Docker container?

JadenSimon commented 1 year ago

@anyfactor @chyld

See this comment. The status bar item is causing some confusion with getting started.

chyld commented 1 year ago

@JadenSimon Yes, that was it. I was initially clicking on the status bar to login. Once I logged in via the side bar explorer it worked perfectly. Thanks!

anyfactor commented 1 year ago

Looks like for some reason, the browser authentication isn't being communicated to the extension.

image

image

anyfactor commented 1 year ago

Solved.

So the issue was that I was not opening the https://device.sso.us-east-1.amazonaws.com/ through VSCode prompt. Rather I was copying the link and opening the site manually separately on the browser. For some reason, the authentication process required VSCode to connect to the site directly through the browser.