Login not working with balena-cli

I am receiving an unexpected error when trying to log in to our openbalena instance via balena-cli (shown below with --debug output). Tried updating to v17.1.5 (latest available as of this writing) and experiencing the same error. Tried deleting my ~/.balena folder with no luck either. Login is confirmed working as it authenticates fine via other channels, and all devices are communicating with the API just fine as well. For some reason this problem is limited to balena-cli.

[debug] new argv=[/opt/balena-cli/balena,/snapshot/balena-cli/bin/balena,login] length=3
[debug] Deprecation check: 0.00232 days since last npm registry query for next major version release date.
[debug] Will not query the registry again until at least 7 days have passed.
 _            _
| |__   __ _ | |  ____  _ __    __ _
| '_ \ / _` || | / __ \| '_ \  / _` |
| |_) | (_) || ||  ___/| | | || (_) |
|_.__/ \__,_||_| \____/|_| |_| \__,_|

Logging in to xxx
? How would you like to login? (Use arrow keys)
? How would you like to login? Credentials
? Email: xxxx@xxxx.com
? Password: [hidden]
BalenaRequestError: Request error: <!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<pre>Cannot GET /actor/v1/whoami</pre>

BalenaRequestError: Request error: <!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<pre>Cannot GET /actor/v1/whoami</pre>

    at Object.<anonymous> (/snapshot/balena-cli/node_modules/balena-request/build/request.js:193:27)
    at Generator.next (<anonymous>)
    at fulfilled (/snapshot/balena-cli/node_modules/tslib/tslib.js)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

For further help or support, visit:

Well, looks like I found the culprit, see below. For anyone who stumbles on this page with the same error, it appears that you can’t use balena-cli past v16.7.6 without upgrading your openbalena instance. Confirmed v16.7.6 is working fine.

<summary> Update balena-sdk to v18 [Otávio Jacobi] </summary>

> ### balena-sdk-18.0.0 - 2023-08-17
> * **BREAKING**: Remove the device-type.json state & name normalization [Thodoris Greasidis]
> * **BREAKING**: Drop auth.getUserActorId in favor of auth.getActorId [Otávio Jacobi]
> * auth: Add getActorId [Otávio Jacobi]
> * **BREAKING**: Drop auth.getUserId in favor of auth.getUserInfo [Otávio Jacobi]
> * **BREAKING**: Drop auth.getEmail in favor of auth.getUserInfo [Otávio Jacobi]
> * auth: Add getUserInfo [Otávio Jacobi]
> * **BREAKING**: Drop pre-Resin OS v1 device.os_version normalization [Thodoris Greasidis]
> * **BREAKING**: Support non-user API keys in auth.isLoggedIn() & whoami() [Otávio Jacobi]
> * **BREAKING**: Drop support to node < 16 [Otávio Jacobi]

Thanks, I had the same issue and thanks to your post I am able to login. One question though: What do you mean with “upgrading your openbalena instance”? I just installed it today, this is the latest version, right?

1 Like

@Cybex take a look in the file compose/versions within the open-balena repo, as of today you will see:


And if you then check out the v0.209.2 tag within the open-balena-api repo, you’ll see that it is about 16 months old. So the “latest” open-balena is a bit of a misnomer when it comes to the underlying application.

We run more current versions of the open-balena apps using custom helm scripts (examples can be found here) - just note that you’ll need a k8s environment to use them.

Thanks, that is very helpful!