# Homewizard P1 Meter - new\_user token API V2

**URL:** <https://discourse.nodered.org/t/homewizard-p1-meter-new-user-token-api-v2/94826>\
**Category:** General\
**Tags:** http-request\
**Created:** [22 January 2025 15:55 UTC](https://discourse.nodered.org/t/homewizard-p1-meter-new-user-token-api-v2/94826 "2025-01-22T15:55:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nice\_to\_have](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@Nice\_to\_have](https://discourse.nodered.org/u/Nice_to_have)\
**Post date:** [22 January 2025 15:55 UTC](https://discourse.nodered.org/t/homewizard-p1-meter-new-user-token-api-v2/94826/1 "2025-01-22T15:55:55Z")

</div>

Hi All,

I recently got the Homewizard P1 Meter.  
Their documentation describes how to request a new user token, but i can not get it to work.

> **[Authorization | HomeWizard Energy API Documentation](https://api-documentation.homewizard.com/docs/v2/authorization/)**
>
> Get a token to authenticate requests to the HomeWizard Energy API.

I have my http post setup as:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/8/c85b54c2d54450dfad991a9f20d6f2149b7df45a.png)

And this gives me:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/1/1112f83e843839ac0814f7fe770e7560b9a5b82b.png)

```auto
[{"id":"a6d766c733eddc04","type":"inject","z":"245407e94549f047","name":"Inject","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":250,"y":220,"wires":[["b3332b0da77eccfb"]]},{"id":"b3332b0da77eccfb","type":"http request","z":"245407e94549f047","name":"Post API Request","method":"POST","ret":"obj","paytoqs":"body","url":"https://192.168.86.32/api/user","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Content-Type","keyValue":"","valueType":"application/json","valueValue":""},{"keyType":"other","keyValue":"X-Api-Version","valueType":"other","valueValue":"2"},{"keyType":"other","keyValue":"name","valueType":"other","valueValue":"local/new_user"}],"x":470,"y":220,"wires":[["f1b847fc3f80a29e"]]},{"id":"f1b847fc3f80a29e","type":"debug","z":"245407e94549f047","name":"Response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":680,"y":220,"wires":[]}]

```

What am i doing wrong?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [22 January 2025 16:49 UTC](https://discourse.nodered.org/t/homewizard-p1-meter-new-user-token-api-v2/94826/2 "2025-01-22T16:49:52Z")

</div>

Have you physically pressed the button on the device

1. The **user opens your app** which initiates a network scan, discovering a device, such as a P1 Meter.
2. After selecting the P1 Meter, the **app sends a `POST /api/user` request** with the [necessary parameters](https://api-documentation.homewizard.com/docs/v2/authorization/#parameters)
3. The device responds with a **`403 Forbidden` status** , indicating that the user must physically press the button on the device to continue.

---

<div class="post-metadata">

**Author:** ![Nice\_to\_have](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@Nice\_to\_have](https://discourse.nodered.org/u/Nice_to_have)\
**Post date:** [22 January 2025 17:03 UTC](https://discourse.nodered.org/t/homewizard-p1-meter-new-user-token-api-v2/94826/3 "2025-01-22T17:03:48Z")

</div>

Even if i press the button, I still get the same error.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [22 January 2025 17:20 UTC](https://discourse.nodered.org/t/homewizard-p1-meter-new-user-token-api-v2/94826/4 "2025-01-22T17:20:33Z")

</div>

All I can think is the new\_user section of the name may need to be a username.

looking again the name needs to be in the payload not the header

```auto
[{"id":"b3332b0da77eccfb","type":"http request","z":"d1395164b4eec73e","name":"Post API Request","method":"POST","ret":"obj","paytoqs":"body","url":"https://192.168.86.32/api/user","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Content-Type","keyValue":"","valueType":"application/json","valueValue":""},{"keyType":"other","keyValue":"X-Api-Version","valueType":"other","valueValue":"2"}],"x":530,"y":6660,"wires":[["f1b847fc3f80a29e"]]},{"id":"a6d766c733eddc04","type":"inject","z":"d1395164b4eec73e","name":"Inject","props":[{"p":"payload,name","v":"local/new_user","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":310,"y":6660,"wires":[["b3332b0da77eccfb"]]},{"id":"f1b847fc3f80a29e","type":"debug","z":"d1395164b4eec73e","name":"Response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":740,"y":6660,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [22 January 2025 17:37 UTC](https://discourse.nodered.org/t/homewizard-p1-meter-new-user-token-api-v2/94826/5 "2025-01-22T17:37:08Z")

</div>

From the node-red system can you `ping 192.168.86.32` ?

On the website the curl example is

```auto
curl https://<IP ADDRESS>/api/user --insecure \ 
-X POST \
-H "Content-Type: application/json" \  
-H "X-Api-Version: 2" \ -d '{"name": "local/new_user"}'

```

it has the --insecure flag which is to connect to server that has self signed certificates ?  
In Node-red you can try to set from your Inject node `msg.rejectUnauthorized` to `false`

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/c/ec32678e8017069db80825904ebc28209bcf7f83.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 April 2025 17:37 UTC](https://discourse.nodered.org/t/homewizard-p1-meter-new-user-token-api-v2/94826/6 "2025-04-22T17:37:15Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
