# Authentication with api\_key

**URL:** <https://community.gladysassistant.com/t/authentification-avec-api-key/6592>\
**Category:** Configuration\
**Tags:** auth-apikey\
**Created:** [October 12, 2021, 5:47pm UTC](https://community.gladysassistant.com/t/authentification-avec-api-key/6592 "2021-10-12T17:47:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [October 12, 2021, 5:47pm UTC](https://community.gladysassistant.com/t/authentification-avec-api-key/6592/1 "2021-10-12T17:47:49Z")

</div>

I noticed that you can create an «&nbsp;api\_key&nbsp;», but when you do this, the token in the session does not have a value in the «&nbsp;valid\_until&nbsp;» field, so requests made with the api\_key are systematically rejected.

Is this intentional? In development? A bug? Not meant to be used? 😃

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [October 13, 2021, 2:07am UTC](https://community.gladysassistant.com/t/authentification-avec-api-key/6592/2 "2021-10-13T02:07:47Z")

</div>

You’re talking about Gladys Plus, right?

If so, that’s not normal, it’s supposed to work.

I talk about it in my live stream «&nbsp;Technical Presentation of Gladys Plus&nbsp;» at 39:16:

[![](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/8/8a61cf26d47238f3bbe79f178b3bc5d0ad3efd90.jpeg "Démonstration & présentation technique de Gladys Plus") ](https://www.youtube.com/watch?v=TmjrBeufjyo&t=964s)

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [October 13, 2021, 6:12am UTC](https://community.gladysassistant.com/t/authentification-avec-api-key/6592/3 "2021-10-13T06:12:19Z")

</div>

Ok, I’ll take a closer look at it 🙂

Since I was able to create an api\_key without the gladys plus, I thought there was a «&nbsp;local&nbsp;» usage.

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [October 13, 2021, 6:27am UTC](https://community.gladysassistant.com/t/authentification-avec-api-key/6592/4 "2021-10-13T06:27:49Z")

</div>

> [@Jean-Philippe](#):
>
> Since I was able to create an api\_key without Gladys Plus, I thought there was a «&nbsp;local&nbsp;» use

Ah ok I understand what you saw in the code 🙂 It’s a relic, I must have done some tests at some point during the alpha, but it’s not used or functional.

On the other hand, there is an open API accessible from anywhere in the world with Gladys Plus.

You have documentation on the site:

> **[Open API | Gladys Assistant](https://gladysassistant.com/fr/docs/plus/open-api/)**
>
> Nous proposons l'Open API Gladys Plus pour permettre aux utilisateurs Gladys Plus d'envoyer des requêtes API depuis l'extérieur de leur réseau.

A simple example to send a new sensor value:

```auto
POST https://api.gladysgateway.com/v1/api/device/state/YOUR_OPEN_API_KEY

Body:
{
    "device_feature_external_id": "mqtt:my-phone-presence",
    "state": 1
}

```

It works on its own and at least it’s accessible from anywhere!

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [October 13, 2021, 6:29am UTC](https://community.gladysassistant.com/t/authentification-avec-api-key/6592/5 "2021-10-13T06:29:32Z")

</div>

Ok, the goal, since I’m migrating from Gladys3 to Gladys4, is for my Zoneminder to trigger a scene when motion is detected, so everything stays local. Therefore, the api\_key suits me well to avoid regenerating a token each time via a script. 😉

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [October 13, 2021, 6:31am UTC](https://community.gladysassistant.com/t/authentification-avec-api-key/6592/6 "2021-10-13T06:31:26Z")

</div>

Ah, in that case why not go through the MQTT API? It’s the simplest and I think zoneminder can send MQTT 🙂

Otherwise, if you can’t get this to work, you can always go through Node-RED as I show in my latest video on YouTube

---

<div class="post-metadata">

**Author:** ![Jean-Philippe](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Jean-Philippe](https://community.gladysassistant.com/u/Jean-Philippe)\
**Post date:** [October 13, 2021, 6:32am UTC](https://community.gladysassistant.com/t/authentification-avec-api-key/6592/7 "2021-10-13T06:32:10Z")

</div>

Yes, I thought about MQTT but it requires me to create a «&nbsp;fake&nbsp;» device of type «&nbsp;motion-detected&nbsp;», it was my fallback solution 😃

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [October 13, 2021, 6:35am UTC](https://community.gladysassistant.com/t/authentification-avec-api-key/6592/8 "2021-10-13T06:35:19Z")

</div>

It seems to me like a good solution, there’s nothing wrong with creating a dummy device 🙂
