# Login not working with balena-cli

**URL:** <https://forums.balena.io/t/login-not-working-with-balena-cli/369153>\
**Category:** openBalena\
**Created:** [October 17, 2023, 3:14am UTC](https://forums.balena.io/t/login-not-working-with-balena-cli/369153 "2023-10-17T03:14:55Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![drcnyc](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@drcnyc](https://forums.balena.io/u/drcnyc)\
**Post date:** [October 17, 2023, 3:14am UTC](https://forums.balena.io/t/login-not-working-with-balena-cli/369153/1 "2023-10-17T03:14:55Z")

</div>

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.

```auto
[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">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /actor/v1/whoami</pre>
</body>
</html>

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

    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:
https://www.balena.io/docs/reference/balena-cli/#support-faq-and-troubleshooting

```

---

<div class="post-metadata">

**Author:** ![drcnyc](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@drcnyc](https://forums.balena.io/u/drcnyc)\
**Post date:** [October 17, 2023, 3:27am UTC](https://forums.balena.io/t/login-not-working-with-balena-cli/369153/2 "2023-10-17T03:27:09Z")

</div>

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.

```auto
<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]

```

---

<div class="post-metadata">

**Author:** ![Cybex](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/cybex/32/9398_2.png) [@Cybex](https://forums.balena.io/u/Cybex)\
**Post date:** [October 17, 2023, 6:02pm UTC](https://forums.balena.io/t/login-not-working-with-balena-cli/369153/3 "2023-10-17T18:02:26Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![drcnyc](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@drcnyc](https://forums.balena.io/u/drcnyc)\
**Post date:** [October 20, 2023, 1:44am UTC](https://forums.balena.io/t/login-not-working-with-balena-cli/369153/4 "2023-10-20T01:44:45Z")

</div>

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

```auto
export OPENBALENA_API_VERSION_TAG=v0.209.2
export OPENBALENA_DB_VERSION_TAG=v5.1.2
export OPENBALENA_MDNS_PUBLISHER_VERSION_TAG=v1.9.2
export OPENBALENA_REGISTRY_VERSION_TAG=v2.25.3
export OPENBALENA_S3_VERSION_TAG=v2.13.10
export OPENBALENA_VPN_VERSION_TAG=v11.4.6

```

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](https://github.com/dcaputo-harmoni/open-balena-helm)) - just note that you’ll need a k8s environment to use them.

---

<div class="post-metadata">

**Author:** ![Cybex](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/cybex/32/9398_2.png) [@Cybex](https://forums.balena.io/u/Cybex)\
**Post date:** [October 20, 2023, 6:59am UTC](https://forums.balena.io/t/login-not-working-with-balena-cli/369153/5 "2023-10-20T06:59:57Z")

</div>

Thanks, that is very helpful!

---

<div class="post-metadata">

**Author:** ![Firat](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/firat/32/8850_2.png) [@Firat](https://forums.balena.io/u/Firat)\
**Post date:** [March 11, 2024, 10:39am UTC](https://forums.balena.io/t/login-not-working-with-balena-cli/369153/7 "2024-03-11T10:39:03Z")

</div>

Hello,  
I would like to reopen this ticket because I have the same problem with the `balena cli 18.0.0` version  
When I try to log in with the credentials previously used for the quickstart script I get the following error

```auto
 Logging in to balena.xxx.io
? How would you like to login? Credentials
? Email: test@xxx.io
? Password: [hidden]
BalenaRequestError: Request error: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /actor/v1/whoami</pre>
</body>
</html>

Additional information may be available with the `--debug` flag.

For further help or support, visit:
https://www.balena.io/docs/reference/balena-cli/#support-faq-and-troubleshooting I use the same 

```

version of the open balena API as @drcnyc

```auto
export OPENBALENA_API_VERSION_TAG=v0.209.2
export OPENBALENA_DB_VERSION_TAG=v5.1.2
export OPENBALENA_MDNS_PUBLISHER_VERSION_TAG=v1.9.2
export OPENBALENA_REGISTRY_VERSION_TAG=v2.25.3
export OPENBALENA_S3_VERSION_TAG=v2.13.10
export OPENBALENA_VPN_VERSION_TAG=v11.4.6

```

At the debug level, when I curl my api

```auto
 ➜ curl -k https://api.xxx.io/ping
OK% 

```

It work.  
I can also connect to the admin page: [GitHub - dcaputo-harmoni/open-balena-admin: Open Balena Admin](https://github.com/dcaputo-harmoni/open-balena-admin) with my credentials but it is impossible to connect with balena cli

---

<div class="post-metadata">

**Author:** ![Firat](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/firat/32/8850_2.png) [@Firat](https://forums.balena.io/u/Firat)\
**Post date:** [March 11, 2024, 10:45am UTC](https://forums.balena.io/t/login-not-working-with-balena-cli/369153/8 "2024-03-11T10:45:50Z")

</div>

ok, I misread the answer…  
I confirm that with version 16.7.6 authentication works.  
It’s a shame that there was a regression on version 18.  
It will be interesting to fix this problem on new versions of balena-cli

---

<div class="post-metadata">

**Author:** ![drcnyc](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@drcnyc](https://forums.balena.io/u/drcnyc)\
**Post date:** [March 11, 2024, 12:20pm UTC](https://forums.balena.io/t/login-not-working-with-balena-cli/369153/9 "2024-03-11T12:20:45Z")

</div>

@Firat it looks like you are using an old version of open-balena-api:

> [@Firat](#):
>
> `v0.209.2`

You will need to upgrade this to be able to use newer versions of balena-cli. Unfortunately, upgrading is not as simple as just changing the version number in that file though - you’ll have to either use one of the solutions developed by members of the community as it requires changes to the various environment variables. I believe there are branches of the open-balena-api repo which do this (using the docker compose deployment methodology) or alternatively you can use one of the helm scripts that are out there if you use k8s.

---

<div class="post-metadata">

**Author:** ![Firat](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/firat/32/8850_2.png) [@Firat](https://forums.balena.io/u/Firat)\
**Post date:** [March 11, 2024, 4:34pm UTC](https://forums.balena.io/t/login-not-working-with-balena-cli/369153/10 "2024-03-11T16:34:36Z")

</div>

Given the number of branches on the git repository, the best solution would be to fix the main branch rather than basing it on a dev branch which can be merged over time

---

<div class="post-metadata">

**Author:** ![drcnyc](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@drcnyc](https://forums.balena.io/u/drcnyc)\
**Post date:** [March 11, 2024, 8:23pm UTC](https://forums.balena.io/t/login-not-working-with-balena-cli/369153/11 "2024-03-11T20:23:35Z")

</div>

@Firat I agree that merging the updates into the main branch would make it easier for new users to get up and running with openbalena. I believe community members have submitted PR’s for some of the branches with these updates, but it would be up to the Balena team to accept them as they control the repository.
