# Open API with long-term authentication token

**URL:** <https://community.gladysassistant.com/t/api-ouverte-avec-jeton-dauthentification-longue-duree/5540>\
**Category:** Demande de fonctionnalités\
**Tags:** feature-core, api, auth-apikey\
**Created:** [September 8, 2020, 8:27pm UTC](https://community.gladysassistant.com/t/api-ouverte-avec-jeton-dauthentification-longue-duree/5540 "2020-09-08T20:27:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![peb](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/peb/32/3480_2.png) [@peb](https://community.gladysassistant.com/u/peb)\
**Post date:** [September 8, 2020, 8:27pm UTC](https://community.gladysassistant.com/t/api-ouverte-avec-jeton-dauthentification-longue-duree/5540/1 "2020-09-08T20:27:43Z")

</div>

In V3, it was possible to generate application tokens to facilitate access to the REST API by adding `&token=xxxxx` in the call.  
This would facilitate the creation of scripts for Automate or Taskr

---

<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:** [September 10, 2020, 8:07am UTC](https://community.gladysassistant.com/t/api-ouverte-avec-jeton-dauthentification-longue-duree/5540/2 "2020-09-10T08:07:24Z")

</div>

Good point, that’s a feature I have in mind! But it’s a good idea to have it here, it will give me an idea of the demand for the open API 🙂

---

<div class="post-metadata">

**Author:** ![peb](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/peb/32/3480_2.png) [@peb](https://community.gladysassistant.com/u/peb)\
**Post date:** [December 7, 2020, 9:21pm UTC](https://community.gladysassistant.com/t/api-ouverte-avec-jeton-dauthentification-longue-duree/5540/3 "2020-12-07T21:21:58Z")

</div>

I’ve added the [associated GitHub issue](https://github.com/GladysAssistant/Gladys/issues/690) for tracking 🙂

_I noticed you renamed the subject, are you going to look into it soon?_ 😃

---

<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:** [December 11, 2020, 8:30am UTC](https://community.gladysassistant.com/t/api-ouverte-avec-jeton-dauthentification-longue-duree/5540/4 "2020-12-11T08:30:42Z")

</div>

> [@peb](#):
>
> _I noticed you renamed the topic, will you look into it soon?_ 😃

It was mainly to give a clearer title to the issue 🙂

Just to know, what interests you in this feature? Which API route interests you the most?

Give me your use cases 🙂

---

<div class="post-metadata">

**Author:** ![peb](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/peb/32/3480_2.png) [@peb](https://community.gladysassistant.com/u/peb)\
**Post date:** [December 11, 2020, 11:14am UTC](https://community.gladysassistant.com/t/api-ouverte-avec-jeton-dauthentification-longue-duree/5540/5 "2020-12-11T11:14:48Z")

</div>

There are two uses:

The first is to facilitate the creation of script automate/tasker.  
I place my phone on the nightstand, it automatically launches an Automate or Gladys scenario → turn on the charger, turn off certain devices, etc…  
So adding the token in the header or at the end of the URL is ideal 🙂

The second is to avoid having to retrieve an authentication token each time it expires in an Android app I am designing. In this case, it’s just to make development easier in the first place, in any case I will implement the retrieval of access tokens via credentials.

Regarding the API routes, it would be to access the on/off of devices, and the color/brightness setting of bulbs, the list of objects by rooms, if possible sortable by one of their characteristics: bulb, brand, maybe on or off.  
If what is written on [the doc](https://apidoc.gladysassistant.com) is still good, it’s already partly possible.

I have a project to transcribe the entire Gladys REST API into a _library_ Kotlin (and maybe Flutter later), in order to facilitate the creation of Android apps for those interested. (And also because I need it in my developments 😃)

---

<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:** [December 11, 2020, 2:49pm UTC](https://community.gladysassistant.com/t/api-ouverte-avec-jeton-dauthentification-longue-duree/5540/6 "2020-12-11T14:49:05Z")

</div>

> [@peb](#):
>
> The first is to facilitate the creation of Automate/Tasker scripts.  
> I place my phone on the nightstand, which automatically launches an Automate or Gladys scenario → turn on the charger, turn off certain devices, etc…  
> So adding the token in the header or at the end of the URL is ideal 🙂

**Ok I see, so:**

1/ Launch a scene from Tasker  
2/ Modify the state of a device from Tasker.

For 2), you can already do this with MQTT (Tasker handles MQTT as far as I know)

Also, in the meantime, you can use MQTT for 1). You create a «&nbsp;virtual&nbsp;» MQTT device that allows you to launch a scene (via a «&nbsp;device state change&nbsp;» trigger)

> [@peb](#):
>
> The second is to avoid having to retrieve an authentication token each time it expires in an Android app I am currently designing. In this case, it’s just to make development easier for the time being, in any case I will implement the retrieval of access tokens via credentials.

Are you designing an Android application? 🙂 Just a question: doesn’t the PWA Gladys Assistant suit you?

Personally, I’ve added Gladys to my home screen and it’s like a native app, I couldn’t tell the difference.

 ![step-6](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/f/f31a5d99a7eda55edab142d34bf919e58c246e20.jpeg) ![step-7](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/7/7672ab2deeed9b6dfc61b2fa3b15b6f051127d01.jpeg)

Tutorial:

> [@Utiliser Gladys Plus comme une application mobile](https://community.gladysassistant.com/t/utiliser-gladys-plus-comme-une-application-mobile/5262):
>
> Salut à tous! Gladys et [Gladys Plus](https://gladysassistant.com/fr/plus/) étant une progressive web app, il est très facile de l’utiliser sur son mobile comme une app native. Vous ne verrez pas la différence avec une application native. Ce tutoriel montre comment utiliser Gladys Plus comme une application native, mais ça marche aussi avec Gladys en local, la seule différence est que vous ne pourrez pas accéder à Gladys hors de votre réseau local. Gladys Plus vous permet d’accéder à Gladys à distance, en chiffré de bout en bout. S…

(I put «&nbsp;Gladys Plus&nbsp;» in the title, but it also works with Gladys Assistant)

---

<div class="post-metadata">

**Author:** ![VonOx](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/vonox/32/10128_2.png) [@VonOx](https://community.gladysassistant.com/u/VonOx)\
**Post date:** [December 11, 2020, 5:26pm UTC](https://community.gladysassistant.com/t/api-ouverte-avec-jeton-dauthentification-longue-duree/5540/7 "2020-12-11T17:26:32Z")

</div>

Same for PWA, it works.

The Tasker + mqtt case is not valid on an external network (Gladys +)

---

<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:** [September 20, 2021, 5:31am UTC](https://community.gladysassistant.com/t/api-ouverte-avec-jeton-dauthentification-longue-duree/5540/8 "2021-09-20T05:31:22Z")

</div>

For those following this conversation, please note that there is an open REST API in Gladys Plus accessible from anywhere in the world!

Here’s a small example of an API call to push a new temperature sensor value remotely:

 ![Screenshot 2021-09-20 at 13.19.51](https://gladys-assistant-community.b-cdn.net/uploads/default/original/2X/9/9ebc876499df0ef645dce1290a5bd6966361c5a2.png)

(The API key has been masked)

I recently demonstrated this API live on YouTube (at 39 minutes):

[![](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=2359)

And there is a tutorial in the documentation:

> **[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.

Feel free to test it out, there is a 14-day free trial: [Gladys Plus | Gladys Assistant](https://gladysassistant.com/fr/plus/)

🙂
