Skip to content
This repository was archived by the owner on May 28, 2024. It is now read-only.
This repository was archived by the owner on May 28, 2024. It is now read-only.

Smart Home: Cache authorization tokens #421

Open
@bramkragten

Description

@bramkragten

For every requestSync or reportState request, a new JWTClient is created, causing a post request to get a new token:

const jwtClient = new google.auth.JWT(

The token that is returned is valid for an hour, but the client and token are still recreated for every request.

I suggest creating the JWTClient just once, on first use, this causes that the token is cached and only refreshed when it is no longer valid.

Furthermore, during the request of a new token, all other requests should wait for this token to finish loading instead of starting a new load.

This will drastically improve the performance and lower the number of requests to the Google Authentication API.

I can create a PR if this is approved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions