Ephigenia/mite-cli

Can't use mite-cli with email address account

daaanny90 opened this issue · 8 comments

Context

  • MacOS Catalina 10.15.7
  • mite-cli 1.5.0

Description

My account is my email address with, of course, the top level domain. When I try to do something with mite-cli I get Hostname/IP does not match certificate's altnames: Host: ****.de.mite.yo.lk. is not in the cert's altnames: DNS:*.mite.yo.lk

Expected Behavior

I should set my account with mite config set account and use mite-cli also with an email address as account name.

Current Behavior

I get Hostname/IP does not match certificate's altnames: Host: ****.de.mite.yo.lk. is not in the cert's altnames: DNS:*.mite.yo.lk

Steps to Reproduce

Set an email address as username and try to use one command of mite-cli.

Possible Solution

I saw in mite-tracker.js on line 11 that the BASE_URL is set with the account saved in config.

The problem, in my case, is that the top domain level .de is wrong, the domain mite should use is the same like my account but without .de.
Maybe is possible to find the top domain level and remove it from the account configuration?
Maybe removing the top domain level from the account with regex and then setting it as BASE_URL?
Or, another solution could be to add a configuration information with the right domain to use.

Right now the "account" value is used as subdomain and prepended to the mite.yo.lk domain name like this <account>.mite.yo.lk. URLs containing "@" characters usually interpreted to contain user and password.

Please check if you set the account value correctly. I’m not sure if that value should contain the @ character.

Maybe this is just a misunderstanding, "account" in the config doesn’t mean you’re mite login name but the subdomain name - the company name. The authentication requires "apiKey" to be set which you can retrieve in the settings of mite.

I tried with my login name, that was maybe the problem. But if I try only with the subdomain name I get Access denied. Please check your credentials.

Did you setup the apiKey using mite config set apiKey <value> ?

I have updated the README to include an example description for the "account" value: https://github.com/Ephigenia/mite-cli#configuration

I tried with the subdomain only, and I always get Access denied. Please check your credentials. and yes, I setup the apiKey with mite config set apiKey <value>

Following your descriptions I've tested what happens when either the x-miteapikey header value (from the apiKey configuration value) is missing and what happens when the subdomain (account from the config) is wrong:

  • "Whoops! We couldn't find your account ''." when the domain is wrong or not existing
  • "Access denied. Please check your credentials." when the api key value is missing, empty or invalid

So it seems that the API Key that you’ve setup is wrong. Please verify that you have the apiKey value setup. You can verify that it it’s correct by trying out a simple CURL request that should return your time-entries. Please fill in subdomain and api key value:

curl --location --request GET 'http://<subdomain>.mite.yo.lk/time_entries.json' \
--header 'X-MiteApiKey: <apikey>'

If that also gives you the error message your API key is not correct.

Oh, yes, I had a Problem with the ApiKey. Now everything works, thank you for your help 👍