balena-io / balena-cli

The official balena CLI tool.
Apache License 2.0
452 stars 138 forks source link

openBalena: "Cannot GET /whoami" or "Cannot GET /user/v1/refresh-token" errors #2211

Open pdcastro opened 3 years ago

pdcastro commented 3 years ago

As originally reported in a forum thread: Balena cli login expired very soon

Within an hour or so of logging in with balena login, running any other CLI command may result in an authentication error:

> balena apps --debug
[debug] new argv=[/home/xxx/balena-cli-v12.38.8/balena,/snapshot/versioned-source/bin/balena,apps] length=3
BalenaRequestError: Request error: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /whoami</pre>
</body>
</html>

Logging in again with balena login works around this issue for another hour or so.

On investigation, we found that the problem is in the balena-request module, which is a dependency of balena's Node SDK. The SDK and that module have already been fixed in the following pull requests, that produced Node SDK v15.30.0:

However, before Node SDK v15.30.0 can be used by the balena CLI, a new backend endpoint (/user/v1/refresh-token) needs to be added to openBalena, as further detailed in issue https://github.com/balena-io/open-balena-api/issues/575.

After that openBalena issue is resolved, the balena CLI can then be updated to use Node SDK v15.30.0, which should then resolve this issue.

jellyfish-bot commented 3 years ago

[pdcastro] This issue has attached support thread https://jel.ly.fish/1627c2d5-220f-4592-bf6f-1bbf277fa151

pdcastro commented 3 years ago

This issue is not yet resolved, just an update: With recent versions of the CLI (I think starting with v11.42.0), the error message on openBalena is: "Cannot GET /user/v1/refresh-token" instead of: "Cannot GET /whoami"

This issue will be resolved when balena-io/open-balena-api#575 is resolved and a new version of openBalena including the new endpoint is released.

thgreasi commented 2 years ago

@pdcastro heads-up that the /user/v1/refresh-token endpoints are now available in open-balena-api v0.181.0.