Closed RikBast closed 1 year ago
Hello, I think the issue in get_token.sh is the use of single quotes preventing the expansion of variables (the "need to hard write the password in the script" issue).
The offending line should be written like this (using surroundings double quotes and escaping the inside double quotes with backslash):
curl -i -s -X POST -H 'Content-Type:application/json' -d "{\"userName\":\"$userName\",\"systemCode\":\"$systemCode\"}" $baseURL/login >$myTempFile
I changed the code in get_token.sh as suggested --> OK
Plus you need to change the baseURL apparently
baseURL="https://eu5.fusionsolar.huawei.com/thirdData"
instead of
baseURL="https://region01eu5.fusionsolar.huawei.com:31942/thirdData"
in the Huawei.env file
Plus you need to change the baseURL apparently
baseURL="https://eu5.fusionsolar.huawei.com/thirdData"
instead of
baseURL="https://region01eu5.fusionsolar.huawei.com:31942/thirdData"
in the Huawei.env file
Correct, I forgot to mention that I did that too, sorry.
Michel,
thnks for the effort on investigating this.
Unfortunetaly for me it still doen't work:
`pi@raspberry-4:~/huawei-solar $ curl -i -s -X POST -H 'Content-Type:application/json' -d "{\"userName\":\"$userName\",\"systemCode\":\"$systemCode\"}" $baseURL/login
HTTP/1.1 200 OK
Server: product only
Date: Sun, 25 Sep 2022 13:37:35 GMT
Content-Type: application/json;charset=UTF-8
Content-Length: 100
Connection: keep-alive
x-frame-options: SAMEORIGIN
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
strict-transport-security: max-age=31536000; includeSubDomains
x-download-options: noopen
set-cookie: JSESSIONID=835FDC37EABE991532978076938FEDA1; Path=/; Secure; HttpOnly
x-trace-enable: false
{"data":null,"success":false,"failCode":20001,"params":{"currentTime":1664113055641},"message":null}
pi@raspberry-4:~/huawei-solar $
` No xsrf-token is available in the output.
I checked the existing of the variables, they are complete and correct:
pi@raspberry-4:~/huawei-solar $ echo $userName, $systemCode, $baseURL AxxxxxxxxxI, ********, https://region01eu5.fusionsolar.huawei.com:31942/thirdData pi@raspberry-4:~/huawei-solar $
Hello, an Error Code "20001" means "The third-party system ID does not exist."
Are you sure of the userName and systemCode (password) you stored into the "HuaweiSolar.env" file ? Beware that this userName is different from the one you use with the regular FusionSolar application (on web or on a smartphone): it must be an openAPI user name you need to ask from your installation company.
Another possible clue is that it seems that the url (for instance: "https://eu5.fusionsolar.huawei.com/thirdData") depends on the region your installation is, and your System ID is only known on the correct management subdomain.
According to some user's manual, they are, for instance:
eu5.fusionsolar.huawei.com | Network management system FusionSolar in Europe
au1.fusionsolar.huawei.com | Network management system FusionSolar in Australia
br1.fusionsolar.huawei.com | Network management system FusionSolar in Brazil
When you log into your management system (something like: https://eu5.fusionsolar.huawei.com/unisso/login.action ), what is the domain name you use ? Is it "eu5.fusionsolar.huawei.com" or another one ?
@GoumJer : I think I see the issue. Your baseURL is "https://region01eu5.fusionsolar.huawei.com:31942" it should be "https://eu5.fusionsolar.huawei.com/thirdData". I think.
Hi, SetUp of HuaweiSolar_API.sh gives the error
"jq: error (at
What is wrong? Thx Meikel
Good evening,
can you post the result of calling
./HuaweiSolar_API.sh Setup Y
so that we see what is going on ? (be sure to remove any username or password if any appear in the result).
Other points to check: in "HuaweiSolar.env":
baseURL="https://eu5.fusionsolar.huawei.com/thirdData"
Good morning, the result of "./HuaweiSolar_API.sh Setup Y" is
New token: No token available"
Base URL and API account is correct, as you can see above. Can you help me?
Regards Meikel
Hello,
it seems that "get_token.sh" does not retrieve the token. Do you mind to try my version (as written above, I found some issues with the one on the repository) ?
Also, are you sure that the directory where "last.token" is to be written is writeable to the user running "get_token.sh" ?
What happens if you manually call "./get_token.sh" (being in the Huawei_Sun2000 directory) ?
Or even better, is the result of (to be executed where "HuaweiSolar.env" is located):
source HuaweiSolar.env ; curl -i -s -X POST -H 'Content-Type:application/json' -d "{\"userName\":\"$userName\",\"systemCode\":\"$systemCode\"}" $baseURL/login
a JSON ?
Hi Michel, everything okay and working now. There was an issue with the Password from Huawei, in there are system characters used in Linux for system operations (# and $) and were a misapprehension error on the server. Fixed it now. Thnx Meikel
pi@csonkat:~/scripts/Huawei-solar $ curl -i -s -X POST -H 'Content-Type:application/json' -d "{\"userName\":\"Cxxxx\",\"systemCode\":\"txxxx\"}" https://eu5.fusionsolar.huawei.com/thirdData/login HTTP/1.1 200 Server: product only Date: Sun, 09 Apr 2023 10:31:37 GMT Content-Type: application/json;charset=UTF-8 Content-Length: 100 Connection: keep-alive upcase-conversion-headers: accessSession,accessSession x-trace-enable: false x-frame-options: SAMEORIGIN x-download-options: noopen x-sampling: true x-parent-id: 7318986683890078083 x-sysprops-sampling: 7318986683890078083 x-autotask-sampling: 1 strict-transport-security: max-age=31536000; includeSubDomains content-security-policy: default-src https: data: blob: ws: 'self' 'unsafe-inline' 'unsafe-eval' x-trace-id: 7318986683890078083 x-content-type-options: nosniff x-xss-protection: 1; mode=block x-span-id: 7318986683890078083 set-cookie: JSESSIONID=936F1098A1105F35C114ADAF8C3FC5AF; Path=/; Secure; HttpOnly
{"data":null,"success":false,"failCode":20003,"params":{"currentTime":1681036297335},"message":null}pi@csonkat:~/scripts/Huawei-solar $
What might be the problem? What does error code 20003 mean?
Hi,
I have no idea what this error code means. It is also not found on the Huawei support forum. Best would be to log a ticket to Huawei support team.
Regards, Jeroen
It's not possible to refresh the token, or maybe I am doing something wrong here.
thx, Rik