Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when creating token file #9

Closed
teHwHoly opened this issue Feb 22, 2024 · 15 comments
Closed

Error when creating token file #9

teHwHoly opened this issue Feb 22, 2024 · 15 comments
Milestone

Comments

@teHwHoly
Copy link

teHwHoly commented Feb 22, 2024

Hi there,

is there a known problem with the communication protocol?
Main branch gave me some protocol errors, so I tried the development branch as it was more recent.
When I want to create the token file, I get the following error:

Internal error.
file:///home/openhabian/niu-cloud-cli-dev/src/createToken.js:100
        yargs().exit(errorCode.FAILED);
        ^

ReferenceError: yargs is not defined
    at file:///home/openhabian/niu-cloud-cli-dev/src/createToken.js:100:9
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v18.19.0
@BlueAndi
Copy link
Owner

Hi, the development branch should work. I am waiting in #8 to get feedback about it. But it looks like something is not working. Let me check it again on my side.

BlueAndi added a commit that referenced this issue Feb 22, 2024
@BlueAndi
Copy link
Owner

I fixed it in the development branch. Unfortunately I have no account anymore to test it, because my time for free usage is over.

@teHwHoly
Copy link
Author

Yes it's a shame that they started the payed access. I cloned the branch again and now I get just the following feedback:
"Internal error."

@teHwHoly
Copy link
Author

I added my credentials in the niu-cloud-connector library and ran the test:

Creating session token ...
Error:
connect ECONNREFUSED 0.0.0.0:443

@teHwHoly
Copy link
Author

teHwHoly commented Feb 23, 2024

My guess is that we have changes in the protocol as mentioned here:
marcelwestrahome/home-assistant-niu-component#31

@BlueAndi
Copy link
Owner

Yes, it looks like. I will have a look what they did in the ha component and see whether I can update accordingly. Let's see whether I can download the current niu app and disassemble it too.

@BlueAndi
Copy link
Owner

BlueAndi commented Feb 24, 2024

Everything should work now again. The problem was that v2 of the authentication API support stopped. Now I am using the v3 of the authentication API.

Please try again and don't forget to update the submodule too. If successful, I will merge it to the master branch and release a new version.

I plan an update to nodejs v20.x.x LTS later (my stupid virtual machine don't like the latest debian at the moment). Currently I am using v18.13.0

@BlueAndi BlueAndi added this to the v2.0.0 milestone Feb 24, 2024
@teHwHoly
Copy link
Author

I'm still getting the feedback "internal error."
Maybe I can find some time in between to alter the api to NIU.
Don't you think we need the other parameters, used eg. here?:
https://github.com/marcelwestrahome/home-assistant-niu-component/blob/master/custom_components/niu/api.py

grant_type, scope and app_id are missing.

@teHwHoly
Copy link
Author

I tried to include the mentioned parameters and also to switch over to md5-hex, but that didn't help so far.

@BlueAndi
Copy link
Owner

Sounds like you didn't update the git submodule. I verified with an account and everything was working. .md5 hash is already considered.

@teHwHoly
Copy link
Author

teHwHoly commented Feb 26, 2024

Do you have any recommendation how to do that?
I used following command to get the ressources:
git clone -b development --recursive https://github.com/BlueAndi/niu-cloud-cli.git niu-cloud-cli
Now I also updated the submodule with:
git clone -b development --recursive https://github.com/BlueAndi/niu-cloud-connector.git niu-cloud-connector
inside the libs folder.
But I still get the internal error message.

@BlueAndi
Copy link
Owner

Can you go inside ./libs/niu-cloud-connector and check there the last log?
And did you after updating an "npm install" again?

@teHwHoly
Copy link
Author

teHwHoly commented Feb 27, 2024

I searched for the log file but wasn't able to find it.
Yes I repeated npm install every time I change dependencies or update the library.

Strangely I still get this error, when running the test of the interface lib:

Error:
connect ECONNREFUSED 0.0.0.0:443

Is it because the domain can't be resolved to an IP?

@BlueAndi
Copy link
Owner

Is it because the domain can't be resolved to an IP?

Hmm ... looks like. Are you in a docker container or something like that?

BTW can you remove the whole local repository on your hard disk and clone again the master branch?

Use the following commands to clone, install and create a token. I am interesting whether you still get the connection refused.

git clone --recursive https://github.com/BlueAndi/niu-cloud-cli
cd niu-cloud-cli
npm install

node niu-cloud-cli.js create_token <your-email-address> <your-password>

@teHwHoly
Copy link
Author

That just gave me the hint I needed.
As DNS wasn't able to resolve the IP I installed and ran dnstracer and accessed the page.
The traffic ran over some filtering algorithms and it was by any reason blocked from resolving the corresponding IP. When routed directly to the dns server I have now success, using the new v3 api with the library.
Many thanks for your support and the great work you did!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants