Writing custom provider - save sessionId in state for subsequent runs

We are writing our first custom provider for Metabase. We have gone through the tutorial & have been able to do CRUD on a basic resource.

As part of authentication, Metabase generates a session-id and expects clients to cache it for 14 days. Link to docs. The login endpoint is rate-limited so this is mandatory.

We are thinking of saving this session-id after 1st login into the state. On subsequent runs,
we would fetch it again from the state & use it to log in. If authentication fails, we would log in with username/password again & update session-id in the state.

We are trying to find a way to do this & haven’t been able to figure it out.

  1. Is this something that should be done in the ConfigureContextFunc?
  2. If yes, do we put it in ResourceData.meta via InstanceState.Meta?
  3. Is there a better, more idiomatic way?

(Apologies if this is something basic or mentioned in the docs)