BalenaRequestError: Request error: Unauthorized


#1

Dear balena team,
first of all, thank you for working on openbalena. The approach of managing iot devices using docker is great.

Unfortunately I have some problems to login with the balena-cli:

I’ve installed openbalena on an Oracle Vm VirtualBox OS Ubuntu 18.04.1 LTS.
Created superuser: ./scripts/quickstart -U super@local -P mypassword -d openbalena.fritz.box
Installed balena-cli on Windows 10 Pro 64bit and copied the ca.crt file from the openbalena server to the client os.

When trying to login I get this error:
BalenaRequestError: Request error: Unauthorized

I scrupulously checked email address and password. I’m not able to find the reason for the error.


#3

Hello @rossiman, how do you invoke the CLI command? You must point the CLI to the location of your server, i.e. invoke it like so:

$ export BALENARC_BALENA_URL=my-domain.com
$ export NODE_EXTRA_CA_CERTS=/path/to/ca.crt
$ balena login

The key is BALENARC_BALENA_URL, but I’ve also added NODE_EXTRA_CA_CERTS for completeness.


#4

Hello @dfunckt,

Thank you for the immediate response. I didn’t set BALENARC_BALENA_URL, but I changed the hosts file as described in How to setup CNAME .

Just for doing a double-check I set BALENARC_BALENA_URL to a wrong url. I got this error:
ENOTFOUND: request to https://api.wrongbalena.fritz.box/login_ failed, reason: getaddrinfo ENOTFOUND api.wrongbalena.fritz.box api.wrongbalena.fritz.box:443

I also tried to set a wrong link for NODE_EXTRA_CA_CERTS. I got this error:
SELF_SIGNED_CERT_IN_CHAIN: request to https://api.openbalena.fritz.box/login_ failed, reason: self signed certificate in certificate chain

Seems that I do have the right value for both settings. I do have access to the api and I use the correct certificate. Is there any restriction/rule for the email address and the password? I use a very simple unsecure combination of super@local password:nix for testing.


#5

@rossiman, could you paste the whole output from the command? This will show the host being used, like so…

$ balena login
 _            _
| |__   __ _ | |  ____  _ __    __ _
| '_ \ / _` || | / __ \| '_ \  / _` |
| |_) | (_) || ||  ___/| | | || (_) |
|_.__/ \__,_||_| \____/|_| |_| \__,_|


Logging in to balena-cloud.com
? How would you like to login? (Use arrow keys)
❯ Web authorization (recommended)
  Credentials
  Authentication token
  I don't have a balena account!

As you can see in the output above, it is using balena-cloud.com. This is a good way to confirm that the requests are going to your OpenBalena install, and not to Balena Cloud.


#6
C:\Users\Stefan>balena login
 _            _
| |__   __ _ | |  ____  _ __    __ _
| '_ \ / _` || | / __ \| '_ \  / _` |
| |_) | (_) || ||  ___/| | | || (_) |
|_.__/ \__,_||_| \____/|_| |_| \__,_|


Logging in to openbalena.fritz.box
? How would you like to login? Credentials
? Email: super@local
? Password: [hidden]
BalenaRequestError: Request error: Unauthorized

If you need help, don't hesitate in contacting us at:

  GitHub: https://github.com/balena-io/balena-cli/issues/new
  Forums: https://forums.balena.io

#7

Hi @richbayliss, hi balena team
I’ve started with a comple new server installation from scratch. Now it’s working! I’m able to login.
I don’t know whats different. I didn’t changed the balena-cli installation on my windows computer.
Thank you for your support


#8

Having the exact same issue on a brand new machine. I setup followed all the instructions in the Getting Started doc, and when I try and login from CLI I am getting BalenaRequestError: Request error: Unauthorized.

I setup user using the quickstart script. Also tried again using the create-superuser script to add a user and still getting same message.

EDIT: looks like the password was truncated due to a special character. re-ran quickstart after deleting the config folder and all is good.


#9

I think I also found how I can solve my problem. After doing new configuration by deleting the config folder and start with quickstart again it did’nt work. I got the same error message when doing the balena login.
After linux reboot it works again.


#10

Seems that I was wrong by telling I can solve my problem. I can not reproduce to fix the problem by reboot. I’ve tried it with a new setup, because I wanted to change to another domain. Again the same error:
BalenaRequestError: Request error: Unauthorized
I don’t know what I’ve done differently to the working setup. Would be great to know which part of the code is throwing the error.


#11

I have the same problem.I have deleted the old openbalena server upgrade to latest version.
Now when using balena login :

SELF_SIGNED_CERT_IN_CHAIN: request to https://api.mydomain.com/login_ failed, reason: self signed certificate in certificate chain

If you need help, don’t hesitate in contacting us at:

GitHub: https://github.com/balena-io/balena-cli/issues/new
Forums: https://forums.balena.io

It would be really helpful if the error message can indicate if the problem is in the client or server side.


#12

To all having the same problems with cli login.
Meanwhile I found a way to get the server running and being able to log in using balena-cli.

I’ve started with a new installation on Ubuntu 18.04.1 x64 server.
I’ve used www.goip.de to define the needed domains. -> How to setup CNAME
I’ve processed all the steps as described in https://www.balena.io/open/docs/getting-started/
I’ve copied the certificate ./open-balena/config/certs/root/ca.crt to the client.
I’ve installed balena-cli, set the env variable to link to the server and the certificate and logged.

Just by deleting the open-balena/config folder and starting by ./scripts/quickstart didn’t work in my case. I always got the Unauthorized error.


#13

I’m getting Unauthorized as well. I have tried all of the suggestions here and reinstalled a few times. Are there any logs, etc. that I should be looking at? Any other debugging suggestions?