wakatime / vscode-wakatime

Visual Studio Code plugin for automatic time tracking and metrics generated from your programming activity.
https://wakatime.com/vs-code
BSD 3-Clause "New" or "Revised" License
1.21k stars 134 forks source link

Invalid API key #316

Closed ktavabi closed 1 year ago

ktavabi commented 1 year ago

I am having no luck getting up and running with the extension on VSCodium Version: 1.73.1 Contents of ~/.wakatime.cfg are...

[settings]
debug = true
api_key = waka_key

I've tried reinstalling the extension and even nuked my account and created a new one but I only see a message saying Invalid API key....check wakatime.com/settings

Console returns

workbench.desktop.main.js:87 [Extension Host] [WakaTime][WARN] Unable to get api key: Error: could not read ~/.wakatime.cfg

Is this file supposed to be written at install? In my case I have to create it and still the same issue. I know this issue is duplicated and closed, but no solutions are available in older issues.

~/.wakatime.log file contents...

{"caller":"cmd/run.go:81","func":"cmd.Run","level":"debug","message":"command: config-read","now":"2022-12-07T23:17:27-08:00","os/arch":"darwin/arm64","version":"v1.60.1"} {"caller":"cmd/run.go:128","func":"cmd.Run","level":"warning","message":"one of the following parameters has to be provided: --config-read, --config-write, --entity, --offline-count, --print-offline-heartbeats, --sync-offline-activity, --today, --today-goal, --useragent, --version","now":"2022-12-07T23:17:59-08:00","os/arch":"darwin/arm64","version":"v1.60.1"} {"caller":"cmd/run.go:128","func":"cmd.Run","level":"warning","message":"one of the following parameters has to be provided: --config-read, --config-write, --entity, --offline-count, --print-offline-heartbeats, --sync-offline-activity, --today, --today-goal, --useragent, --version","now":"2022-12-07T23:18:25-08:00","os/arch":"darwin/arm64","version":"v1.60.1"}

alanhamlett commented 1 year ago

Does it work if you remove the waka_ prefix from your api key?

Maybe somehow you're using an old version of the plugin before it supported the new api key format.

alanhamlett commented 1 year ago

Actually, Unable to get api key: Error: could not read ~/.wakatime.cfg is probably the reason. Can you delete that file and restart vscode to let it create the cfg file again? If the plugin can't read the cfg file it will think there's no api key available.

ktavabi commented 1 year ago

Does it work if you remove the waka_ prefix from your api key?

The original issue seems to be resolved when I remove waka_. TBS, the API key on the user settings page clearly has waka_ prepended, which is rather confusing.

The extension is still unable to communicate with my dashboard. Below is the tail from ~/.wakatime.log...

{"caller":"cmd/run.go:270","file":".../Brewfile","func":"cmd.runCmd","is_write":true,"level":"error","lineno":93,"message":"failed to run command: sending heartbeat(s) failed: api error: failed making request to \"https://api.wakatime.com/api/v1/users/current/heartbeats.bulk\": Post \"https://api.wakatime.com/api/v1/users/current/heartbeats.bulk\": proxyconnect tcp: dial tcp [::1]:8080: connect: connection refused","now":"2022-12-12T14:31:36-08:00","os/arch":"darwin/arm64","plugin":"vscode/1.74.0 vscode-wakatime/22.1.0","time":1670884296.305658,"version":"v1.60.1"} {"caller":"cmd/run.go:270","func":"cmd.runCmd","level":"error","message":"failed to run command: today fetch failed: failed fetching today from api: failed to make request to \"https://api.wakatime.com/api/v1/users/current/statusbar/today\": Get \"https://api.wakatime.com/api/v1/users/current/statusbar/today\": proxyconnect tcp: dial tcp [::1]:8080: connect: connection refused","now":"2022-12-12T14:32:10-08:00","os/arch":"darwin/arm64","version":"v1.60.1"} {"caller":"cmd/run.go:270","file":"/Users/kam/.wakatime.log","func":"cmd.runCmd","level":"error","lineno":1,"message":"failed to run command: sending heartbeat(s) failed: api error: failed making request to \"https://api.wakatime.com/api/v1/users/current/heartbeats.bulk\": Post \"https://api.wakatime.com/api/v1/users/current/heartbeats.bulk\": proxyconnect tcp: dial tcp [::1]:8080: connect: connection refused","now":"2022-12-12T15:03:38-08:00","os/arch":"darwin/arm64","plugin":"vscode/1.74.0 vscode-wakatime/22.1.0","time":1670886218.695998,"version":"v1.60.1"}

alanhamlett commented 1 year ago

The error is an invalid proxy: proxyconnect tcp: dial tcp [::1]:8080: connect: connection refused.

Try removing any proxy line from your ~/.wakatime.cfg and it should work after re-opening vscode.

ktavabi commented 1 year ago

Thanks for the FB, Alan. I got the thing to work finally after a clean environment rebuild, and minimal configuration with an API key without the waka_ prefix.

alanhamlett commented 1 year ago

It should work with the prefix too now.

ktavabi commented 1 year ago

Someone else can verify that...🙃