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.23k stars 137 forks source link

VSCode still requiring an API key although one is set inside `.wakatime.cfg` #256

Closed mainrs closed 2 years ago

mainrs commented 2 years ago

I'd expect the extension to pick the key from the configuration file automatically without me having to enter it in again.

alanhamlett commented 2 years ago

It should... the vscode plugin doesn't have any other way to get your api key. Maybe your ~/.wakatime.cfg file was corrupted, or vscode encountered an error when reading it?

liyuhang1997 commented 2 years ago

Sometimes it pops up for no reason and I have to re-enter the API Key.

mainrs commented 2 years ago

Sometimes it pops up for no reason and I have to re-enter the API Key.

That’s the behavior I do encounter as well. I double checked it the files. I’ve first created the config file. I then installed the extension. And upon first launching vscode with the extension, it prompted me for the key. Even though the key was present in the confit file.

alanhamlett commented 2 years ago

Please send your ~/.wakatime.log file to support@wakatime.com. What I'm looking for is an error message saying either failed to read in config or invalid api key. That will tell us if it's asking for your api key because it couldn't read the cfg file, or because the API returned an unauthorized response.

You might need to turn on debug mode for the error message to be logged.

Edit: Also, the next time it asks for your api key before entering it can you send the contents of ~/.wakatime.cfg to support@wakatime.com? Maybe the cfg file is getting corrupted somehow.

liyuhang1997 commented 2 years ago

请将您的~/.wakatime.log文件发送至support@wakatime.com。我正在寻找的是一条错误消息,上面写着failed to read in configor invalid api key。这将告诉我们它是否因为无法读取 cfg 文件而请求您的 api 密钥,或者因为 API 返回了未经授权的响应。

您可能需要打开调试模式才能记录错误消息。

编辑:另外,下次它在输入之前询问您的 api 密钥时,您可以将 ~/.wakatime.cfg 的内容发送到support@wakatime.com吗?也许cfg文件以某种方式损坏。

.wakatime.cfg

[internal]
backoff_at      = 2022-01-30T17:18:01+08:00
backoff_retries = 1
alanhamlett commented 2 years ago

Do you also use Atom with WakaTime? We just fixed a bug in the atom-wakatime plugin that might have been corrupting your ~/.wakatime.cfg file in certain cases. If you delete your ~/.wakatime.cfg file and restart vscode does it start working again?

mrgnhnt96 commented 2 years ago

I am having this issue as well, it is very annoying. If you try to ignore it, it will pop up every time a file is saved, opened, or closed. It forces you to add the key to stop being bothered by it. Sometimes it will last for a few days without asking again, other times it will ask after a couple of hours

alanhamlett commented 2 years ago

@jeetsdev what's the contents of your ~/.wakatime.cfg file? Please remove your api key before sharing the file.

jeetsdev commented 2 years ago

@jeetsdev what's the contents of your ~/.wakatime.cfg file? Please remove your api key before sharing the file.

Here it is-

[internal]
backoff_at      = 2022-02-02T09:18:55+05:30
backoff_retries = 1

[settings]
api_key = "my API key"
alanhamlett commented 2 years ago

That's valid and shouldn't cause the failed to load command parameters: failed to load api params: failed to load api key error. Maybe this is a bug in wakatime-cli instead of vscode.

kdoroszewicz commented 2 years ago

Yesterday I was encountering the same bug as @mrgnhnt96. I input my key multiple times, disable and enabled wakatime extension (from the command palette) and nothing worked. The extension kept asking me for the api key. Today it's working again with no additional changes on my side 🤷‍♂️

alanhamlett commented 2 years ago

Can you try with the latest release just now v18.0.5?

If it's still asking for your api key after updating the plugin, please add a comment here with your:

kdoroszewicz commented 2 years ago

Can you try with the latest release just now v18.0.5?

If it's still asking for your api key after updating the plugin, please add a comment here with your:

  • OS (Win/Linux/Mac)
  • contents of your ~/.wakatime.cfg file (with api key removed)
  • any error messages seen in your vscode dev console window
  • your full log file at ~/.wakatime.log

@alanhamlett over the past 5 days it seems to bo working correctly. Not once I was asked for the api token and everything is tracked properly.