apption-labs / meater-cloud-public-rest-api

MEATER Cloud REST API documentation.
87 stars 4 forks source link

How long is the login JWT token valid? #8

Closed Novanic closed 3 years ago

Novanic commented 3 years ago

How long is the login JWT token valid? That should get mentioned within the documentation or when the login has to get re-executed.

I would execute the following:

  1. login endpoint
  2. the /devices endpoint for example 1 time per minute to check if a device is active
  3. when a device is active the /devices endpoint will get executed every 10 seconds for example to get current data and to process the cook data
  4. when there is no device active anymore, back to step 2.

When do I notice that I should execute step 1 (login) again? Or should I execute it together with step 2 one time per minute? Or has the /device endpoint a specific response code that indicates that a new login call is required?

Thank you in advance. :-)

Novanic commented 3 years ago

Ok, I found it out. The documentation says already "The JWT doesn't expire but may be reset.". When I send a false (or outdated) token to the /devices endpoint, response code 401 is returned. So my solution is to execute only 1 login initially and after that only executing a new login when the /devices endpoint responds with response code 401.

Could you please document that 401 is returned in that case? Then it should be safe to rely on that behaviour.

Thank you! :-)

nojacko commented 3 years ago

401 is the expected response as it's the standard http status code. I've added it to the list of expected error responses.