GlueHome / homebridge-plugin

Homebrige plugin to integrate with Glue ecosystem.
Apache License 2.0
10 stars 4 forks source link

Can't get a API key #28

Closed arnonfarn closed 1 year ago

arnonfarn commented 1 year ago

Describe The Bug:

I followed the instructions and have tried several times, but I get no data back when I execute the curl command To Reproduce:

curl -i --location --request POST 'https://user-api.gluehome.com/v1/api-keys' \ --header 'Content-Type: application/json' \ -u "username":"password" \ --data-raw '{ "name": "My Test Key", "scopes": ["events.read", "locks.read", "locks.write"] }' Expected behavior:

A API key Logs: HTTP/2 404 date: Mon, 13 Feb 2023 14:34:48 GMT content-length: 0 glue-correlation-id: cdd19f6b x-xss-protection: 1; mode=block x-content-type-options: nosniff x-frame-options: deny content-security-policy: default-src 'self' referrer-policy: no-referrer strict-transport-security: max-age=15724800; includeSubDomains cf-cache-status: DYNAMIC report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=MgFXptcbyA97QhqrUP8T9JDCjJlEImWhCz1W00yFdkC5WnnR6QN0nx6Q7ZTC9esflPCTx7Tj2xd1wem050uwE6v0QZgn7LyAjgWcQPvADCIPj9cV0qar2jDhTsvfHDXMkV3XYGL8Bc8%3D"}],"group":"cf-nel","max_age":604800} nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800} x-glue-greeting: Hej server: cloudflare cf-ray: 798e49770a9535fa-FRA alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400

curl: (3) URL using bad/illegal format or missing URL curl: (3) URL using bad/illegal format or missing URL curl: (3) nested brace in URL position 34: {"name": "My Test Key","scopes": ["events.read", "locks.read", "locks.write"]}``` Show the Homebridge logs here, remove any sensitive information.


**Plugin Config:**

```json
Show your Homebridge config.json here, remove any sensitive information.

Screenshots:

Environment:

arnonfarn commented 1 year ago

I would like to know more about this error, curl: (3) URL using bad/illegal format or missing URL curl: (3) URL using bad/illegal format or missing URL curl: (3) nested brace in URL position 34: {"name": "My Test Key","scopes": ["events.read", "locks.read", "locks.write"]}```

arnonfarn commented 1 year ago

It was my fault, tried to run it as a single line script. But when I used your syntax inside a script file it worked. So now I can get api keys. However when I interact with it, only one lock, locks?

Can I get the API for my new lock? I have several locks.

Example curl -L -H "Authorization: Api-Key xxxxxxx" -H 'Content-Type: application/json' -d '{"type":"lock"}' https://user-api.gluehome.com/v1/locks/xxx-f799-447f-9024-e5xxxxxxx7/operations

andycb commented 1 year ago

Hi,

The endpoint you're calling will get you the operations for a specific lock https://user-api.gluehome.com/v1/locks/{LockId}/operations

You can get all of the locks on your account by making a GET request to https://user-api.gluehome.com/v1/locks/. In the response to that, you'll get the ID of each lock.

You can then call the above for each of those IDs. Unfortunately there isn't a single endpoint to get all operations for all locks.

The API docs are here if you need more details: https://user-api.gluehome.com/v1/docs/index.html

arnonfarn commented 1 year ago

Thanks!

Could you give me a curl command example to get the information?

arnonfarn commented 1 year ago

This did the magic, now I have access to all locks! Without homekit, thanks! Maybe it can help another newbie like me.

curl -L -H "Authorization: Api-Key xxxxx" https://user-api.gluehome.com/v1/locks

arnonfarn commented 1 year ago

It's working as expected now. Can control the different locks with your api and a few curl commands. It's integrated into HA, so it will lock and unlock for example if I arm my alarm.

I really hope you keep the api open in the future, because it's working perfectly.