SmartThings CLI smartthings apps fails with TypeError: Invalid URL after login

Hello SmartThings Developer Support,

I am using the SmartThings CLI on Windows to manage my SmartThings apps. After running `smartthings login`, my browser opens and redirects me to a localhost URL like:

http://localhost:61973/finish?code=2RoZxx

However, after that, when I try to list my apps:

smartthings apps

I get the following error:

TypeError: Invalid URL
Code: ERR_INVALID_URL

Environment details:

  • OS: Windows 10/11
  • Node.js version: (please insert your version)
  • SmartThings CLI version: (please insert your version)

Steps I have tried:

  1. Logging out and back in
  2. Updating CLI to the latest version
  3. Restarting the terminal

Could you please help me understand why this error occurs and how to fix it?

Thank you.
Dyaa Kassoma

Tagging @nayelyz @Itati

Hi, @Dyaa_4
Sorry, we’re on holiday today.
After a quick scan, I noticed you’re using a localhost URL.
You need to use an HTTPS URL for the redirect URI.
Tools such as Ngrok can help you create a tunnel for the local port you open using an HTTPS URL.

Hey, thank you. Ah, okay. But that’s not the problem. I tried to log in with the new version of the SmartThings CLI, and after that I got this message.

The CLI doesn’t have a login command so that’s odd, but when first used with a valid conmand that needs the API it will open a browser to do an OAUTH authorisation. That URL is handled by the CLI itself and you should have seen a message something like ‘You can close this window’. If you didn’t then something is wrong.

At some stage you will probably also have had a popup from Windows to allow the CLI access to node.js. That will be important.

I’d be tempted to do smartthings --version to make sure you do indeed have the latest version which I believe is 2.1.1. If you need to update from a version 1.x.y installation I suggest doing smartthings logout as the location of the configuration directory has been moved between major releases and it will move the config file for you. You might like to do that anyway so you can start over.

It may be useful to set SMARTTHINGS_DEBUG=true to make the CLI a bit more chatty and then try smartthings apps again.

That’s odd. That’s normally means something like invalid characters in a URL. The debugging might be enlightening.

Sorry for the confusion, @Dyaa_4
I tried to use the command you mentioned but the CLI rejects it so it’s odd you even got a different error as @orangebucket said.
Please let us know the result of the tests mentioned by Graham above.

Hey,

i works now for me i got “You can close the window.” on http://localhost:61973/finish?code=59kDGp

and got the right code for my auth.

thank you so much